I was creating this VBA to add in some details for recording purpose. Then I wanted to remove it from the email body before sending it out. Most of the time it ran, sometimes it didn’t. Not sure if there is any error in my code.
Dispatch_remark = " Dispatched to " & OutMail.To & "; " & OutMail.CC & " on " & Format(Now(), "yyyy-mm-dd hh:mm:ss") OutMail.HTMLBody = Replace(OutMail.HTMLBody, FirstSentence, FirstSentence & Dispatch_remark, 1, 1) OutMail.HTMLBody = Replace(OutMail.HTMLBody, Dispatch_remark, "", 1, 1)
Example: FirstSentence is “123456”; Dispatch_remark is ” Dispatched to Tony Nguyen; email@example.com; firstname.lastname@example.org;”
My first line in the email body will look somthing like this: “123456 Distached to Tony…”
The 3rd line of the code above is my attempt to remove the ” Dispatched to…” part. But sometimes it doesn’t work. I think it might have something with the font or format but not sure.
Here is an example of where the Dispatch_remark cannot be removed from my email body:
Dispatched to Tony Nguyen; 香港 (email@example.com); 香港 (firstname.lastname@example.org) on 2020-03-21 11:00:15;