Send Outlook Email from VBA


Send Outlook Email from Access

Send email to outlook from an Access form can really enhance the capability of your contact management database.  In this example we add a button automatically launch outlook using the contact’s email address contained on the form.
Run MS Outlook Access FormThe first step is to locate the e-mail client, outlook.exe, on the system that uses the application. For example on the Windows XP Professional operating system using Office XP with a standard installation the outlook client can be found in C:Program FilesMicrosoft OfficeOffice10. You can simply hard code the location of the e-mail client directly into your code but I prefer to store it in a table, giving the user a simple interface to the table where they can enter the location themselves if necessary.

We have three examples showing how you can make your Access database interact with Outlook Email functions:

The concept behind this is to use outlook command line options to launch an e-mail message with the address from the form. New! Download Access example of  Sending Email to Outlook

  • Simply add a button to the form and in the OnClick event add the following code. Note that the e-mail address is in a control named ContactEmail in this example.

    Private Sub btnEmail_Click()
    Dim EmailClient As Variant
    Dim stAppName As String
    Dim ClientName As String

    On Error GoTo Err_btnEmail_Click

    � Look up the base directory of the e-mail client in table EmailClient
    EmailClient = Trim(DLookup(“OutLookAddress”, “EmailClient”))
    If IsNull(EmailClient) Then
    ‘ Open a simple form asking the user to enter the base directory
    DoCmd.OpenForm “EmailClient”, , , , acFormAdd
    If Not IsNull(Me!ContactEmail) And Not IsNull(EmailClient) Then
    ‘ if there is a on the end remove it
    If InStr(Len(EmailClient), EmailClient, “”) Then
    EmailClient = Left(EmailClient, Len(EmailClient) – 1)
    End If
    � add the outlook client, set the command line options, add the form address
    stAppName = EmailClient & “outlook.exe /c ipm.note /m ” & Me!ContactEmail
    � Launch Outlook
    Call Shell(stAppName, 1)
    MsgBox “The Email Client or Email Address is Null, please enter it”
    (adsbygoogle = window.adsbygoogle || []).push({});

       End If
    End If
    Exit Sub

    MsgBox Err.Description
    Resume Exit_btnEmail_Click

    End Sub

    The important command line information is on the line

    stAppName = EmailClient & “outlook.exe /c ipm.note /m ” & Me!ContactEmail


  •  /c indicates create an object

  •  ipm.note specifies that you want an e-mail message

  •  /m says use the following e-mail address in To:

  •  Me!ContactEmail pulls the e-mail address from the form


Microsoft Office:
MS Access 2000 Through 2016 and Office 365 & Sharepoint


Microsoft Office VBA, MS Access 2003, 2007, 2010, 2013, 2016