Hello,
I have an interesting issue where I am attemping to embed an image within an email body. I first export these charts as .GIF images to a shared drive that myself and other users have access to. When I send these emails to myself, I can see the charts perfectly fine. However, when I send these charts to other users, all they can see are broken images (boxes with X's in them). All of the recievers of the message have confirmed read/write access to the shared file location, and can open up the images at that location as well as the attachments from the email- they just can't see the embedded images within the email itself.
My thought is that for some reason the images arent sourcing correctly to where they are stored. I can foresee two, maybe three potential solutions to this problem, although I don't know how to accomplish them- hopefully all of you fine folks can help.
Potential solution 1: Export the .GIF images to temporary internet files that can be accessed by others INSTEAD of relying on a shared drive.
Potential solution 2: Embed the images BUT once they are in the email, remove the links to the files they originate from, leaving just a static embedded image.
Potential solution 3: Somehow embed the images not from the orignal image source, but from the attachments themselves. I.E attach all relevant GIF's first, then embed them not from a file location, but from the actual attachment.
Any help is much appreciated, hopefully i was clear and one of my proposed solutions is technically feasible. Unfortunately, I dont have the knowledge to code them out.
Please see a snippet of code below. Some things such as example, test, etc have been puposefully changed from their true values.
Sub MultipleSendOffCharts()
Dim OutApp As Object
Dim OutMail As Object
Dim Fname1 As String
Dim FnameRoot As String
Dim bdy As String
'Turn on Outlook for Excel
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Save off each chart to where you will
FnameRoot = "S:\Public\Example\"
Fname1 = FnameRoot & "test.gif"
With ActiveWorkbook.Worksheets("ExampleWorksheet").ChartObjects("ExampleChart")
.Activate
.Chart.Export FileName:=Fname1, FilterName:="GIF"
End With
'send E-mail
With OutMail
.To = "MyEmail@Example.com"
.CC = ""
.BCC = ""
.Subject = "Sample"
.Attachments.Add Fname1
'HTML body for image
bdy = "<img src='S:\Public\Example\test.gif'>"
'Now add it into body
.HTMLBody=bdy
'send email
.Send
End With
Set OutMail = Nothing
Set OutApp = Nothing
ActiveWorkbook.EnvelopeVisible = False
'Turn off Excel save notifcation
Application.DisplayAlerts = False
End Sub
Appreciate the help guys
Bookmarks