Reputation: 63
I have a .Net desktop program that uses Interop to send emails via Outlook. When sending to multiple recipients it uses an email per recipient as the salutation is substituted for personalization. The body of the emails is inserted from a Word file as follows (shortened for clarity):
objOutlook = New Outlook.Application
objItem = objOutlook.CreateItem(Outlook.OlItemType.olMailItem)
Dim inspector As Outlook.Inspector = objItem.GetInspector
Dim wordDoc As Word.Document = inspector.WordEditor
wordDoc.Activate() 'Not sure what this does but seems to be needed !
'Insert file contents into body of email.
Dim currentRange As Word.Range = wordDoc.Application.Selection.Range
currentRange.InsertFile(fileName,,,, False)
If at this point I now do an ObjItem.Display, followed by ObjItem.Send then it works perfectly. The Word file contents are put into the email body and the email sent.
But if I simply do an ObjItem.Send (without the .Display) then the email is sent with a blank body.
How do I force the email body to be set with the Word content without having to show the email ?
Upvotes: 0
Views: 160
Reputation: 49397
Try to call the Save method of the MailItem class.
Also you may try to save the document to a file in the HTML format and then set the HTMLBody property of the MailItem class.
Upvotes: 0