Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

help automating HTML e-mails

Status
Not open for further replies.

BuilderSpec

Programmer
Dec 24, 2003
383
0
0
GB
Hi

I have an access database which creates multiple HTML emails read from a recordset. It uses Outlook to create each e-mail and I specify it as HTML format. I have posted the code below and it works fine. the only issue I have is that I have to get outlook to display each email and then save it so that the html is saved in the email. If i run the same code without msg.display line then it saves all the emails but there is nothing in them i.e. the HTML is missing from the body. If i leave it in it works but it takes a long time as it displays each email it creates then saves it.

how do I get it to save the HTML in the email without me having to display each one ?

the code below is a snippet of my whole code, but everything to do with the outlook email is there.




Dim oa As Outlook.Application
Dim msg As Outlook.MailItem
Set oa = CreateObject("Outlook.Application")

rs.open a recordset 'pseudocode for completeness
while not rs.eof

Set msg = oa.CreateItem(olMailItem)

msg.To = "test@test.com"

msg.BodyFormat = olFormatHTML

msg.HTMLBody = Me.Template

msg.Subject = Nz(Me.txtSubject, "")

msg.Display False
msg.Save

msg.Close olSave

rs.MoveNext
Loop
rs.Close

Hope this helps!

Regards

BuilderSpec
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top