I am sending emails using VBA with Outlook (Office 365), based on an HTML formatted template (.oft). It's somewhat heavy due to some images (2Mb total)
Many times it works fine.
Sometimes it loses the HTML formatting, and sends a plain text email (same recipient, same template, same sender, same hardware / software).
Two things I tried.
- Slow down the loading of template (application.wait)
- Setting the format explicitly as HTML
row = 2
Do While Sheets("invitees").Cells(row, 1) <> ""
Email_Send_To = Sheets("invitees").Cells(row, 1)
Set Mail_Single = Mail_Object.CreateItemFromTemplate("K:\Path\Product Update.oft")
Application.Wait (Now + #12:00:04 AM#) 'didn't help
With Mail_Single
.To = Email_Send_To
.SentOnBehalfOfName = Email_Send_From
.Subject = "Product Update"
.BodyFormat = olFormatHTML 'didn't help
.Send
End With
row = row + 1
Loop
I stripped the code down to
Set Mail_Single = Mail_Object.CreateItemFromTemplate("K:\Path\Product Update.oft")
MsgBox (Mail_Single.BodyFormat) 'the output is olFormatHTML as expected
Mail_Single.Close (olSave)
In the drafts, my email is consistently text only.
If I send the template manually, it goes as HTML (both Outlook and Gmail render it accurately).