BuilderSpec
Programmer
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
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