Send an HTML email based on a template from within Access

A

Andrew R

Hi

I am trying to send an email with some information from a recordset as
part of a vba sub.

The preceding code builds up the variables which hold the email
address, the details to be put in the message and the subject line. I
then have this line of code:

DoCmd.SendObject , , acFormatHTML, strEmail, , "(e-mail address removed)",
rsEmail(3), strDetails, False,
"C:\databases\emailtemplates\Emailtostore.htm"

The field(3) referred to in the recordset holds my subject line. the
other variables are all declared and populating without problems.

My issue is that the email generates and sends, but as a plain text
email. The code above specifies both that this should be an HTML email
and the use of a template (in C:\Databases...) but both these seem to
be ignored. I've tried removing the Format argument to allow it to
simply pick up the HTML file as the template, but with no luck.

Anyone any ideas?

Thanks in advance

Regards
Andrew
 
R

Ron2006

There may be a disconnect in the send object

The format part may be fine, except when loading html email via the
other method you have to load HTMLBody not BODY

Here is some code that works.

+++++++++++++++++++++++++++++++++++++
Set o = CreateObject("Outlook.Application")
Set m = o.CreateItem(0)


m.To = Forms![HiddenKey]![HManagerEmail]
' m.cc = for copies

' m.bcc = for blind copies

m.Subject = "Defect Analysis for " & Forms![fieldname]

' m.body = "now is the time" if html not
desired

==================================
m.bodyformat = 2 ' not necessary if no html

m.htmlbody = Chr(13) & Chr(13) & _
"<body><Table><tr><td><b> Date: </b></td><td>" & Date &
"</td></tr>" & _
"<tr><td><b>Manager: </b></td><td>" &
Forms![HiddenKey]![HManager] & "</td></tr>" & _
"<tr><td><b>Name: </b></td><td>" &
Forms![HiddenKey]![HCompany] & "</td></tr>" & _

"<tr><td></td><td></td></tr>" & _
"</Table></body>"
===================================

' m.send ' to send it instead of displaying it.
m.Display

++++++++++++++++++++++++++++++++++++++

watch out for word wraps in the posting.

Ron
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top