Sending HTML E-mails

James Deckert

Continuing to Learn
Local time
Today, 17:01
Joined
Oct 6, 2005
Messages
189
When I send an HTML e-mail, I must display the message, for the body to be
placed in the email. If I comment out the .display, the body of the email is
blank. I'd prefer not to display the message.

below is my code.

Dim objOutlook As Outlook.Application
Dim objMsg As Outlook.MailItem

Set objOutlook = CreateObject("Outlook.Application")
Set objMsg = objOutlook.CreateItem(olMailItem)
strBody = Replace(strBody, vbCrLf, "<br>")
With objMsg
.To = strRecipient
.Subject = strSubject
.BodyFormat = olFormatHTML
.HTMLBody = strBody
.Display ' body only appears if I Display first. Don't know why.
.Send
End With

Set objOutlook = Nothing
Set objMsg = Nothing

The ".BodyFormat = olFormatHTML" doesn't seem to make a difference whether it is there or not.

I'm aware of sendobject, but have never been able to get it to convert HTML tags to the appropriate format. Here is the code I use
DoCmd.SendObject acSendNoObject, , acFormatHTML, strRecipient, , , strSubject, strBody, False

Help with either would be great.
Any ideas?
James
 

Users who are viewing this thread

Back
Top Bottom