I've been developing a code in VBA to treat a worksheet on Excel and send the result to my customer via e-mail, attaching the document and an image in the body of e-mail.
A part of this code, uses a HTML code to attach the image.
When I send this automatic e-mail to my customer, the image is blocked by a default protection of Outlook, that don't permit automatic download of HTML images.
The below is an example of my code, wherein myMail.HTMLBody is where I add the directory of image and the problem happens.
I can send the image to my customer via e-mail without block when I see the e-mail (in myMail.Display True), where I do the manual process in MS Outlook, clicking in Insert > Pictures and choose the image (this process that I want in my code).
How can I write this process (choose the image manually in Pictures) in my code?
I could request my customer define my e-mail as trusted or request them to uncheck this protection in Trust Center of MS Outlook, but I want to solve this problem from my side and not pass it to my customer.
Function Send_Email(EmailTO, EmailCC)
Dim outlookApp As Outlook.Application
Dim myMail As Outlook.MailItem
Dim Source_File As String
Set outlookApp = New Outlook.Application
Set myMail = outlookApp.CreateItem(olMailItem)
myMail.To = EmailTO
myMail.CC = EmailCC
myMail.Subject = "Subject
myMail.HTMLBody = "<p><img src=""C:\pictures\image.png"" alt="""" /></p>
myMail.Attachments.Add "C:\pictures\image.png"
myMail.Attachments.Add "C:\documents\document.xlsx"
myMail.Display True 'comment this out if you don't want to display email
myMail.Send 'comment this out if you don't want to send yet
End Function