Generate rich (HTML) e-mail message using VBA (1 Viewer)

MrHans

Registered User
Local time
Today, 10:55
Joined
Jul 27, 2015
Messages
147
Hello all,

I currently use an Access database to store my customer details.
In this database I created forms to search, select and view the customer details. On the form, I created the option to generate and e-mail message, to this particular customer. This is working fine, except for the fact that these e-mails are in plain text, without any pictures and just not looking great... it's 2016 so there should be nicer methods available...

So, I would like to change my existing code to generate nice looking, rich, html formatted e-mails. I was thinking about using a Word template and filling that in, but I'm not sure. Do you have any idea's?
What are the common methods for generating nice looking e-mails?

Thanks in advance.

My current code:
Code:
Private Sub cmdCreateMail_Click()
On Error GoTo Err_cmdCreateMail_Click

    Dim objOutlook As Outlook.Application
    Dim objOutlookMsg As Outlook.MailItem
    Dim objOutlookRecip As Outlook.Recipient

    ' Create the Outlook session.
    Set objOutlook = CreateObject("Outlook.Application")

    ' Create the message.
    Set objOutlookMsg = objOutlook.CreateItem(olMailItem)

    With objOutlookMsg
        ' Add the To recipient(s) to the message.
        Set objOutlookRecip = .Recipients.Add("info@xxxxxx.nl")
        objOutlookRecip.Type = olTo

        ' Set the Subject, Body, and Importance of the message.
        .Subject = "This is the e-mail subject"
        .Body = "Dear mister," & vbNewLine _
                & vbNewLine _
                & "Installer company: " & Me.fldFitterCompanyName & vbNewLine _
                & "Installer name: " & Me.fldFitterName & vbNewLine _
                & "Date: " & Me.fldFitterDateInstalled & vbNewLine _
                & vbNewLine _
                & "With kind regards," & vbNewLine _
                & "Companyname"

        ' Resolve each Recipient's name.
        For Each objOutlookRecip In .Recipients
            objOutlookRecip.Resolve
        Next
        .Display

    End With

    Set objOutlook = Nothing


Exit_cmdCreateMail_Click:
    Set objOutlook = Nothing
    Exit Sub

Err_cmdCreateMail_Click:
    MsgBox "Errorcode = " & Err.Number & vbNewLine & _
        "Description = " & Err.Description, vbOKOnly + vbCritical, conAppName
    Resume Exit_cmdCreateMail_Click

End Sub
 

MrHans

Registered User
Local time
Today, 10:55
Joined
Jul 27, 2015
Messages
147
Thanks, but I am actually looking for a solution where you can use an Word template, fill in the bookmarks and merge it to e-mail.

I understand the htmlbody property, but I think this is mainly for font option. I also want to use pictures, header, footer and background color... Should all of this be done manually using htmlbody?
 

Frothingslosh

Premier Pale Stale Ale
Local time
Today, 04:55
Joined
Oct 17, 2012
Messages
3,276

Users who are viewing this thread

Top Bottom