My code is creating a mail item from a template, rewriting the body and then saving it as a draft.
The problem is that when the vba object for the mail item is set to Nothing the message in the drafts folder is lost and replaced with some other text.
Dim objMail As Outlook.MailItem
Set objMail = Outlook.Application.CreateItemFromTemplate(stTemplate)
stMsgText = objMail.Body
Call FitConfirmMailText ' this populates stMsgText with text
objMail.Body = stMsgText
objMail.To = strCustEmail
objMail.Subject = strSubject
If strApptType = "frm25leads" Then
objMail.Attachments.Add ("H:\John Lewis\Masters\quality assured (v2).pdf")
Set objMail = Nothing
The debug.prints all show the right text.
When the message appears in the drafts folder after objmail.close olsave it is the correct message, but as soon as set objMail=Nothing it changes to a different and incorrect body (the subject is correct). The same thing happens when the procedure finishes if I remark out the Set objMail=Nothing
How can setting the object to nothing replace the body of the item?
NB: There is other code in the procedure, but it doesn't work with objMail.
I am not using a namespace object. Is that the problem?