How to avoid the Outlook Security warning for email automation - VBA

30,491

Solution 1

This is a partial answer. I have made it a Community Wiki answer in the expectation that someone else can explain the final part which I cannot get to work.

This web page, http://msdn.microsoft.com/en-us/library/office/aa155754(v=office.10).aspx , explains the first three parts of the process. It was written in 1999 so cannot be followed exactly because it refers to old versions of Windows and Office.

The first step is to add Digital Signature for VBA Projects to your Office installation although I found it under Shared Tools rather than Office Tools. Don't make the mistake of just adding Digital Signature for VBA Projects to Outlook because, as I discovered, that means you uninstall Word, Excel, etc.

The second step is to run Selfcert.exe to create a digital certificate in your own name.

The third step is to open Outlook's VBA editor, select Tools then Digital Certificate then Choose to sign the project with your certificate.

With these steps you can suppress the warning that Outlook contains macros but this does not suppress that warning that a macro is accessing emails. To suppress that warning, you need a fourth step which is to place your certificate within the Trusted Root Certificate Authorities Store. This web page http://technet.microsoft.com/en-us/library/cc962065.aspx explains about the Certification Authority Trust Model but I cannot successfully use Microsoft Management Console to achieve the fourth step.

Solution 2

Instead .send use the following:

.Display 'displays outlook email
Application.SendKeys "%s" 'presses send as a send key

note: be careful when using display keys, if you move the mouse and click while the program is running it can change whats going on. also outlook will display on ur screen and send.. if you working on something else's and this bothers you, yea.. not the best idea

Share:
30,491
Paolo Bernasconi
Author by

Paolo Bernasconi

A programmer

Updated on June 24, 2020

Comments

  • Paolo Bernasconi
    Paolo Bernasconi almost 4 years

    I'm trying to send an email from Excel 2010 in VBA, through Outlook 2010. Most other answers on SO don't seem to have any method of using VBA to do this, nor for Outlook/Excel 2010.

    Do any free methods exist? The Redemption method won't be a viable option, unless it is easy to install on 10 machines inside of a large company.

    This is how I currently send emails:

    Dim emailAddr As String
    Dim OutApp As Object
    Dim OutMail As Object
    
    Set OutApp = CreateObject("Outlook.Application")
    Set OutMail = OutApp.CreateItem(0)
    With OutMail
     .To = "[email protected]"
     .Subject = "Demande"
     .HtmlBody = CombinedValueHtml
     .Send
    End With
    
    Set OutMail = Nothing
    Set OutApp = Nothing
    
    Exit Sub
    

    Thanks for all your help in advance.