"A program is trying to automatically send e-mail on your behalf." (1 Viewer)

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi,

Upgrading an Access 2000 database to Access 2003, integrating with Outlook 2003.

I get the message:
A program is trying to automatically send e-mail on your behalf.
Do you want to allow this?
If this is unexpected, it may be a virus and you should choose "No".

This interrupts the automated process in my VBA script.

I know this is caused by the Outlook E-mail Security Update, and have reviewed the workaround options in this MS article: http://support.microsoft.com/default.aspx?scid=kb;en-us;263084

The options given by Microsoft are:
1. customize the behavior of the Outlook E-mail Security Update. Our Exchange administrator is looking at this option now, but obviously it is far from desirable if it compromises the intended security features of Outlook.

2. use CDO for Windows (CDOSYS). I would like to try this but I can't find the full syntax to work with the classes in CDOSYS. I need to send messages, but also look up addresses without requiring user interaction.

3. use Extended MAPI. I would like to try this but I can't find the full syntax to work with Extended MAPI. I thought I had found an example but it used CDO 1.2 and caused the same error.

4. Create a COM add-in for Outlook. I would like to try this but the example given is for VB 6.0, and I would not know how to do this in Access.

So, has anyone had to integrate Access 2003 with Outlook 2003, and could give me syntax to create an email message which the user can check before sending, and to lookup a full or partial Outlook id in the address book and get the Outlook user's name.

Many thanks,
Keith.
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 21:45
Joined
Feb 19, 2002
Messages
43,233
I can't answer any of your questions because luckily, I haven't had to face the problem. However, there is a mail application that will work as a substitute. You can find it (and a trial version) at www.fmsinc.com.
 

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi Pat,

I'm not sure the product Total Access Emailer will meet my needs. It says "Total Access Emailer avoids this problem by using SMTP rather than Outlook."

However, I need to use Outlook to allow the system to validate network user ids against the outlook address book, and generate Outlook emails which the user can then preview in Outlook before sending. Sorry if I didn't make this clear in my original description.

Thanks,
Keith.
 

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi,

Thanks for all your replies. Looks like I might need to try using Redemption, which if it works as described, should allow me to do everything I need.

ClickYes will not work for me as the scripts are running as a result of user interaction, so the user would see the message popup and then disappear, which would be disorienting to say the least. It sounds as though it might compromise your security as well, if you are not very careful.

Many thanks,
Keith.
 

BCullenward

Registered User.
Local time
Yesterday, 20:45
Joined
Jul 6, 2005
Messages
28
Used to have the same problem, try this

Code:
Public Sub SendMessage(strTo As String, strFrom As String, strBCC As String, strAttachment2 As String)
    'Send using the Port on a SMTP server
    Dim attList() As String
    Dim item As Integer
    Dim iMsg 
    Dim iConf 
    Dim Flds 
    Dim strHTML
    Dim stBody1 As String, stBody2 As String, stSubject As String
    Set iMsg = CreateObject("CDO.Message")
    Set iConf = CreateObject("CDO.configuration")
    Set Flds = iConf.Fields
    'Set lfsFile1 = CreateObject("Scripting.FileSystemObject")
    With Flds
        .item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
         .item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
        .item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "YOUR.MAIL.SERVER"
        'Use SSL to connect to the SMTP server:
        .item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 10
        .Update
    End With

    If InStr(strAttachment2, ";") Then attList = Split(strAttachment2, ";")

    With iMsg
        Set .Configuration = iConf
        .To = strTo
        '.CC = strCC
        .FROM = strFrom
        .BCC = strBCC
        '.Subject = strSubject
        '.HTMLBody = strHTML
        '.TextBody = strMessage
        '.Nocoverpage: True
        '.confirmsend: true
        If InStr(strAttachment2, ";") Then
            For item = 1 To UBound(attList)
                .addAttachment (attList(item))
            Next
        Else
            If Not IsNull(strAttachment2) And Len(strAttachment2) > 0 Then .addAttachment strAttachment2
        End If
        .Send
    End With
    
    ' cleanup of variables
    Set iMsg = Nothing
    Set iConf = Nothing
    Set Flds = Nothing
End Sub
 

modest

Registered User.
Local time
Yesterday, 21:45
Joined
Jan 4, 2005
Messages
1,220
You can use SMTP or Redemption, your choice. However, I think SMTP has to be on your network (Microsoft Exchange Server). Personally, I've posted on Redemption before. If the thread wasn't deleted (because of the hacking), it has some sample code.

Redemption is a .dll file that wraps your email in the extended MAPI so that it avoids the security prompt. The problem is that you have to be able to save/install this .dll on every computer that uses the database. Which is a problem if you dont have install rights on your computer and if a lot of people use the database.


Note that you can see more information about Bcullenward's sample at, which includes wrapping in HTML:
http://support.microsoft.com/kb/286431/
 
Last edited:

modest

Registered User.
Local time
Yesterday, 21:45
Joined
Jan 4, 2005
Messages
1,220
Found the thread with some Redemption stuff:
http://www.access-programmers.co.uk/forums/showthread.php?t=83434&highlight=redemption


Additionally, with SMTP you don't need to install anything, just use a Microsoft schema, choose the port and you're set. You can send anyone a message on your mail server. Remember that Microsoft set up all this security so crackers/hackers could not send things from your mail account without you know it. This is an effort to minimize the spamming and the speed at which viruses are spread.
 
Last edited:

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi,

The SMTP method works OK for part of my requirement. The problem remains, I have existing code that I use to resolve the Outlook id of a user defined on MS Exchange, including the entry of a partial id. So for example a user can enter "kwi" and the system will resolve it to "kwilliams", the same as Outlook itself can do. I use the following code:

Dim objRecipient As Recipient
Dim objMailItem As MailItem

'Create a new Outlook mail object.
Set objMailItem = gobj_Outlook.CreateItem(olMailItem)

With objMailItem
'Add the name as a recipient to the mail object, and attempt to resolve it.
Set objRecipient = .Recipients.Add(argId)
objRecipient.Resolve
If Not objRecipient.Resolved Then
:
:

This is the essential bit of the code, which uses an existing instance of Outlook in a global variable gobj_outlook.

Can the equivalent be done in SMTP mail - I guess not? Is there another way of validating user ids - the same ids will exist in Active Directory, if there is a way I can do that.

Thanks,
Keith.

PS I've posted the full code for the method I use below:

Code:
Function GetOutlookId(argId As String)
' -------------------------------------------------------------------------------------
' Resolve a specified full or partial Exchange user name and return the resolved unique
' name.
' -------------------------------------------------------------------------------------
    'Dim gobj_Outlook As Outlook.Application
    Dim objRecipient As Recipient
    Dim objMailItem As MailItem
    Dim strAddressElement() As String, strAddressId As String, strNameId As String, strNameElement() As String
    Dim lngDelayCount As Long, lngLimitDelay As Long
    
    'If a null name was passed, return an empty string.
    If IsNull(argId) Then
        GetOutlookId = ""
        Exit Function
    End If
    
    'Create a new Outlook mail object.
    Set objMailItem = gobj_Outlook.CreateItem(olMailItem)
    
    With objMailItem
        'Add the name as a recipient to the mail object, and attempt to resolve it.
        Set objRecipient = .Recipients.Add(argId)
        objRecipient.Resolve
        If Not objRecipient.Resolved Then
            'If name could not be resolved, return an empty string.
            GetOutlookId = ""
        Else
            'Split the name into two parts; the last part is the desired id.
            strAddressElement = Split(objRecipient.Address, "=")
            strAddressId = strAddressElement(UBound(strAddressElement))
            'Verify that id found matches fragment supplied, otherwise could cause problems
            'with people whose names have changed. If not, use the name found.
            If Left(strAddressId, Len(argId)) = argId Then
                'Return the found id.
                GetOutlookId = strAddressId
            Else
                'Extract the id from the resolved name.
                strNameElement = Split(objRecipient.Name, " ")
                If UBound(strNameElement) > 0 Then
                    'Construct an alternative id from the first initial and the last name.
                    strNameId = LCase(Left(strNameElement(UBound(strNameElement) - 1), 1) & strNameElement(UBound(strNameElement)))
                    'Verify that id found matches fragment supplied.
                    If Left(strNameId, Len(argId)) = argId Then
                        GetOutlookId = strNameId
                    Else
                        'No match, so revert to the original passed id.
                        GetOutlookId = argId
                    End If
                Else
                    'No match, so revert to the original passed id.
                    GetOutlookId = argId
                End If
            End If
        End If
    End With
    
    'Clean up resources used.
    Set objRecipient = Nothing
    Set objMailItem = Nothing
End Function
 
Last edited:

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi,

After a further review of the Microsoft support site and this site, I wonder if I can use LDAP for Active Directory to check for a user id. Does anyone have a simple code sample? What are the software requirements for a machine running Access to be able to make LDAP queries? Does it need any special LDAP client software?

Thanks again,
Keith.
 

modest

Registered User.
Local time
Yesterday, 21:45
Joined
Jan 4, 2005
Messages
1,220
To answer your other question: SMTP is not really a software, its a protocol. It stands for Simple Mail Transfer Protocol; you can't look up or do anything with it anymore then you could with TCP/IP information - it's just a way of setting up and sending/receiving packets. The software that handles the user information would be on the Mail Server, in this case the Microsoft Exchange Server. I'm assuming the reason you don't want to use Outlook for this easy-lookup ability is in the case someone doesn't have Outlook installed? I'm not sure why you don't keep using Outlook, but I would assume if you wanted to get down to it, the LDAP would be a way to be more independent.


KeithWilliams said:
After a further review of the Microsoft support site and this site, I wonder if I can use LDAP for Active Directory to check for a user id. Does anyone have a simple code sample? What are the software requirements for a machine running Access to be able to make LDAP queries? Does it need any special LDAP client software?

Haha, I see you're where I was a year ago. For some reason, at my other work, I was not able to successfully achieve everything I wanted to with LDAP, so I'm not sure if you will be able to or not. I haven't tried it on my current company's systems so I don't know if it was a programming error or a system problem.

For starters, do a search on LDAP on this forum. I think I've provided some useful links and sample code (if not I have some at home). You will need to make a reference to the ActiveDirectory library (I think it's listed as Active DS in the reference list). Not to mention, you will need your LDAP connection string/password.

-Modest
 
Last edited:

KeithWilliams

Registered User.
Local time
Today, 02:45
Joined
Feb 9, 2004
Messages
137
Hi Modest,

Thanks for your reply. I was using SMTP to try to get around the Outlook Security Update, which gives the message I described at the beginning of this thread.

I have already looked for LDAP posts, but the one you linked to in this forum had disappeared. I think there was a problem caused by the site being hacked recently...?

I am now experimenting with Outlook Redemption, and it looks like it might meet all my needs.

Thanks,
Keith.
 

Users who are viewing this thread

Top Bottom