Send individual emails from MS Access 2013 using an Outlook Template (Need detailed step by step)

I have an Access 2013 DB which has my list of contacts of a project... I also have 4 different email templates in Outlook that I use to send emails to my contacts depending on their needs.  I want to be able to send the same email to multiple user from withing Access using the Outlook template that I have already created.
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
Patrick Matthews has a detailed article regarding this:

This includes a sample database. Using that, try to implement your email process, and post back here with specific questions.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
omgangIT ManagerCommented:
Definitely should follow up on Scott's suggestion and read Patrick Matthews excellent article.  Still, I developed a routine years ago (Access 2000) to do exactly what you describe.  I later updated it to use the Outlook Redemption library (mentioned in Patrick Matthew's article) to work around the Outlook security model introduced in Outlook 2007.

You may note there is no error handler; I typically used this routine to send multiple thousands of messages over night to a large constituent list (my original routine included a pause every couple of minutes to allow the Outlook Outbox to clear out).  Also, there is a call to a separate function to construct the message body; this was used when a template wasn't being utilized.

The code is pretty well commented but please let me know if you have any questions.
OM Gang

Sub SendRedemptionMessage(Reg As String)
'SendMessage procedure modified to use Outlook Redemption
On Error Resume Next

        'declare and open instance of MS Outlook
    Dim db As DAO.Database
    Dim rs As DAO.Recordset
    Dim olOutlook As New Outlook.Application
    Dim olOutlookMsg As Outlook.MailItem
    Dim olOutlookRecip As Outlook.Recipient
    Dim olOutlookAttach As Outlook.Attachment
    Dim olInspector
    Dim RedemptionSafeItem As Object
    Dim strMsgBody As String, strAttachmentName As String
    Dim strRecipList As String, strAttachmentPath As String
    Dim strTemplateName As String, strTemplatePath As String
    Dim blBuildBody As Boolean, blAttachment As Boolean
    Dim blUseStationary As Boolean, blUseTemplate As Boolean
    Dim blDisplayMsg As Boolean

        'message body
    'blBuildBody = True          'call function to build message body
    blBuildBody = False         'don't build message body
    'blAttachment = True         'include attachment
    blAttachment = False        'don't include attachment
        'assign attachment path to string variable
    strAttachmentPath = "P:\OMGang\Attachments\"
        'assign name of attachment to string variable
    strAttachmentName = "The_Attachment_I_Want_To_Send.pdf"
        'message template
    'blUseTemplate = True        'use pre-built Outlook template
    blUseTemplate = False       'don't use template
        'assign template path to string variable
    strTemplatePath = "P:\OMGang\Templates\"
    strTemplateName = "Template.oft"
        'message stationary
    blUseStationary = True      'use default Outlook stationary
    'blUseStationary = False     'don't use stationary
        'display message option
    'blDisplayMsg = True         'display message before sending
    blDisplayMsg = False        'don't display
        'assign name table or query containing the recipient list
    'strRecipList = "qryRecipients"      'production
    strRecipList = "tblTemp"            'testing

'end configuration----------------------------------------

        'build message body?
    If blBuildBody = True Then

            'build message body for this region
            'function call - this module
            'returns "Failed" on error
        strMsgBody = BuildMsg(Reg)
        If strMsgBody = "Failed" Then
                'call error handler with specifics - this module
            Call ErrorHandler("BuildMsg", 1, False)
            GoTo Exit_SendRedemptionMessage
        End If
    End If
        'create instance of current database
    Set db = CurrentDb
        'open recordset based on table/query - recipients
    Set rs = db.OpenRecordset(strRecipList)
        'move to first record
        'loop through recipients and build message for each
    Do Until rs.EOF
            'use message template
        If blUseTemplate = True Then
            Set olOutlookMsg = olOutlook.CreateItemFromTemplate(strTemplatePath _
                    & strTemplateName)
        ElseIf blUseStationary = True Then
                'create new message using Outlook defaults.  Outlook should be configured with a default
                'stationary for all new messages
            Set olOutlookMsg = olOutlook.CreateItem(olMailItem)
        End If
            'not needed
        'Set olInspector = olOutlookMsg.GetInspector

        With olOutlookMsg
            Set olOutlookRecip = .Recipients.Add(rs!emlAddress)
            olOutlookRecip.Type = olTo

                'subject, body, importance
            .Subject = "This is the Subject for the message"
                'include message body?
            If blBuildBody = True Then
                .Body = strMsgBody
            End If
            .Importance = olImportanceNormal

            If blAttachment = True Then
                Set olOutlookAttach = .Attachments.Add(strAttachmentPath _
                        & strAttachmentName, , , strAttachmentName)
            End If
                'switch to Redemption safe item
            Set RedemptionSafeItem = CreateObject("Redemption.SafeMailItem")
            RedemptionSafeItem.Item = olOutlookMsg

'do I need this?
                'send redemption safe item

        End With
            'move to next recipient record
        'clear object variables
    Set RedemptionSafeItem = Nothing
    Set olInspector = Nothing
    Set olOutlookAttach = Nothing
    Set olOutlookRecip = Nothing
    Set olOutlookMsg = Nothing
    Set olOutlook = Nothing
    If Not rs Is Nothing Then rs.Close
        Set rs = Nothing
    Set db = Nothing
    Exit Sub

End Sub

Open in new window

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.