Hi all,
First post, apologies in advance if this has been answered elsewhere but I could not find a solution to my specific issue.
So I have an Excel 2010 file, on a single sheet I have five charts which get updated and sent to a distribution list every morning. Process in code is to export each of the charts to a temporary directory as .png format, build a html body (referencing the files in cid format) and display the email to check over and send. When the email is viewed in Outlook, the images are displayed correctly, however when viewed form a mobile the user gets empty boxes with "cid:chartname.png" in the top left corner of each box.
Everywhere else I have looked, people seem to be having trouble getting the files attached, which is not the case here, it seems to be compatibility issues with mobile devices (although I'd gladly admit I'm wrong if someone could point me in the right direction).
Code is as follows:
Dim varOutlook As Object
Dim varMailItem As Object
Dim varChartObject As ChartObject
Dim varChart As Chart
Dim varFilename As String
Dim varPath As String
Dim varCount As Integer
Dim varBody As String
Dim varFSO As Object
Dim varFSOFile As Object
Dim varBase As String
For varCount = 1 To ThisWorkbook.Sheets("Parameters").ChartObjects.Count
DoEvents
Set varChartObject = Sheets("Parameters").ChartObjects(varCount)
Set varChart = varChartObject.Chart
varFilename = Format(Now, "YYYYMMDD") & Format(varCount, "00")
varPath = Environ("temp")
On Error Resume Next
Kill varPath & "\" & varFilename
On Error GoTo 0
varChart.Export Filename:=varPath & "\" & varFilename & ".png", Filtername:="PNG"
Set varChartObject = Nothing
Set varChart = Nothing
Next varCount
varBody = varBody & "<br><img src= 'cid:" & Format(Now, "YYYYMMDD") & "01.png'>"
varBody = varBody & "<br><img src= 'cid:" & Format(Now, "YYYYMMDD") & "02.png'>"
varBody = varBody & "<br><img src= 'cid:" & Format(Now, "YYYYMMDD") & "03.png'>"
varBody = varBody & "<br><img src= 'cid:" & Format(Now, "YYYYMMDD") & "04.png'>"
varBody = varBody & "<br><img src= 'cid:" & Format(Now, "YYYYMMDD") & "05.png'>"
Set varOutlook = CreateObject("Outlook.application")
Set varMailItem = varOutlook.CreateItem(0)
With varMailItem
.Subject = "My Subject".Attachments.Add varPath & "\" & Format(Now, "YYYYMMDD") & "01.png"
.Attachments.Add varPath & "\" & Format(Now, "YYYYMMDD") & "02.png"
.Attachments.Add varPath & "\" & Format(Now, "YYYYMMDD") & "03.png"
.Attachments.Add varPath & "\" & Format(Now, "YYYYMMDD") & "04.png"
.Attachments.Add varPath & "\" & Format(Now, "YYYYMMDD") & "05.png"
.HTMLBody = varBody
.To = "distribution@example.com"
.Display
End With
Set varMailItem = Nothing
Set varOutlook = Nothing
Any help would be greatly appreciated
Bookmarks