3
votes

I am sending email by automating outlook from excel and have managed to bypass the pesky warning message about viruses using sendkeys (with inspector activate just prior to call to sendkeys).

Now I sometimes get a message about allowing access to contacts. I have the email addresses for the recipients and don't need to access the contacts, but outlook autoresolve kicks in and then a pop up about allowing access to the contacts appears. This doesn't have the 5 second delay, but it still prevents the system being fully automated. I'm trying to avoid using 3rd party tools like redemption and I was wondering if anyone has found a way to turn autoresolve off.

I've read posts on other sites suggesting turning off autocomplete and automatic name checking, but outlook still attempts to resolve the address when the mail is sent.

Any pointers would be gladly received.

Edit 24/08/13

I have heard that if you outlook 2007 and above and a correctly installed system with a Microsoft approved virus scanner you will not see the message, but I don't have control over the installation of programs on the users machines.

The code that I have tried includes

Function Mailit(byval sMessageTo as String, byval sSamplerCenter as String, byval sFileSpec as String)

Dim olApp As outlook.Application
Dim objMail As Outlook.MailItem
Dim blnOLOpen As Boolean

    On Error Resume Next
    Set olApp = GetObject(, "Outlook.Application")
    blnOLOpen = True
    On Error Goto 0

    If olApp Is Nothing Then
        Set olApp = CreateObject("Outlook.Application")
        blnOLOpen = False
    End If

    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
       .To = sMessageTo
       .Subject = sSampleCenter
       .Attachments.Add sFileSpec
       .Send
    End With

This causes the warning message about viruses and causes a 5 second wait before a user can choose to send the mail. The sendkeys method I use is the same up to the With objMail but then does the following:

Dim myInspector As Outlook.Inspector


With objMail
.To = MessageTo
.Subject = SampleCenter
.Attachments.Add FileSpec
.Display
End With

Set myInspector = objMail.GetInspector
myInspector.Activate
SendKeys "%s", True

I also have some code for checking that the number of items in the sent folder has increased and waiting/calling the inspector and sendkeys function if it hasn't. This method doesn't lead to the warning, but often results in a dialog box asking if the user wishes to allow access to their contacts.

1
Are you using VBA code to actually create/send the email? Or are you using sendkeys to cause the entire process to happen? I've sent a lot of email (using purely VBA code) and never had either of these problems.enderland
I don't think I can help but, here's a couple of thoughts. What happens if you Save the emails and send them later? Does using ResolveAll help? Also, as a side note, I don't think you need to test with GetObjecet as only one Outlook instance is allowed, so CreateObject gets the existing instance if there is one.Doug Glancy
What are you trying to attach? Installers/Executables will raise that warning. Is it possible to ZIP the file before attaching it?David Zemens
@DougGlancy I have tried resolve all, but this triggers the message about accessing the contacts folder. I will have a think about saving them, there may be something in that. On the side note I agree generally with what you are saying, the reason I test if the app is already open is because I will close outlook if it was not already open.Graham Anderson
In my mail sending apps I always used an exposed macro in outlook that I could acces from excel. And I never had a problem. Outlook sends the message itself, so it has no problem accessing the contacts/resolving the adresses - and you have no problems with the virus message.Johanness

1 Answers

1
votes

In Outlook: Go to Options -> E-Mail and disable the checkbox "Resolve names automatically".