Tech Support Guy banner
Status
Not open for further replies.

Sending email with HTML from within MS Access 2013

1K views 1 reply 2 participants last post by  keltic1der 
#1 ·
I don't know if anyone else has had a problem with the boring-ness of plain text emails. The following is code that works. I'm sure the moderators will delete if it's not a worthwhile post for the forum.
Step 1
Set up your mail as a string with the html code embedded. You can use bold and
  1. ordered lists and
  2. list items e.g.

    hardcode = "

    The IRC Cover page indicates that the policy is due for review.
    The version of the policy currently being used by the university can be viewed by clicking on the following link. http://put link here!

    "
    hardcode = hardcode & "

    Please ignore this message if the Policy is currently under review.

    "

    Body = line1 & hardcode
    Step 2
    Put all your text into the HTML body tag (you can use headings as well - I didn't need them)
    Body = "" & Body & ""

    Step 3
    Add the .BodyFormat and .HTMLBody to your outlook call
    Set OutApp = CreateObject("Outlook.Application")
    OutApp.Session.Logon
    Set OutMail = OutApp.CreateItem(0)
    On Error Resume Next
    With OutMail
    .To = emailaddress
    .CC = CC
    .BCC = ""
    .Subject = Subject
    .BodyFormat = olFormatHTML '2 'old Format HTML
    .HTMLBody = Body
    .Send
    End With
    On Error GoTo 0
    'MsgBox "Send successful, Thank you " & filepathname & flname & " sent to " & emailaddress
    Set OutMail = Nothing
    Set OutApp = Nothing

    DoCmd.SetWarnings True
    Exit_Sendemail:
    Exit Sub

    Err_Sendemail:
    MsgBox Err.Description
    Resume Exit_Sendemail:
    End Sub
 
See less See more
Status
Not open for further replies.
You have insufficient privileges to reply here.
Top