Hi all,
I'm using Excel 2010, and the code below works but it's not optimal.
I'm trying to create a vba code that attaches a chart into the body of an e-mail to be viewed by e-mail (outside of network) and iphone.
Searching online, I found a way to export the chart into a Local/Network/Sharepoint drive, then HTML img source the file back into the e-mail. However, this process requires that the file remains on the disk or network drive. If the file is deleted, then no image will appear, and If it's on the network, it slowly loads, especially on sharepoint
Any suggestions? cutting and pasting would be ideal but I don't think that is supported....
Ranny
----------------------------
Code:
Sub Sendmail()
'Working in 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim Fname As String
'Turn on Outlook for Excel
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Path name
Fname = "X:\roni_" & Format(Date, "dd-mm-yy") & ".jpg"
' X is mapped to sharepoint site C:\Users\rkhano\AppData\Roaming\Microsoft\Windows\Network Shortcuts\Sharepoint\roni_" & Format(Date, "dd-mm-yy") & ".jpg"
'Action on worksheet
ActiveWorkbook.Worksheets("Hourly").ChartObjects("Chart 1").Chart.Export Filename:=Fname, FilterName:="jpg"
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Test Chart"
.Attachments.Add Fname
'replace x with <
s = "xpxHourly US GMV Chartxpx"
s = s & "xpxximg src=file://" & Fname & "xx/px"
s = "xHTMLxxBODYx" & s & "xHTMLxxBODYx"
.HTMLBody = s
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
I'm using Excel 2010, and the code below works but it's not optimal.
I'm trying to create a vba code that attaches a chart into the body of an e-mail to be viewed by e-mail (outside of network) and iphone.
Searching online, I found a way to export the chart into a Local/Network/Sharepoint drive, then HTML img source the file back into the e-mail. However, this process requires that the file remains on the disk or network drive. If the file is deleted, then no image will appear, and If it's on the network, it slowly loads, especially on sharepoint
Any suggestions? cutting and pasting would be ideal but I don't think that is supported....
Ranny
----------------------------
Code:
Sub Sendmail()
'Working in 2000-2010
Dim OutApp As Object
Dim OutMail As Object
Dim Fname As String
'Turn on Outlook for Excel
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
'Path name
Fname = "X:\roni_" & Format(Date, "dd-mm-yy") & ".jpg"
' X is mapped to sharepoint site C:\Users\rkhano\AppData\Roaming\Microsoft\Windows\Network Shortcuts\Sharepoint\roni_" & Format(Date, "dd-mm-yy") & ".jpg"
'Action on worksheet
ActiveWorkbook.Worksheets("Hourly").ChartObjects("Chart 1").Chart.Export Filename:=Fname, FilterName:="jpg"
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = "Test Chart"
.Attachments.Add Fname
'replace x with <
s = "xpxHourly US GMV Chartxpx"
s = s & "xpxximg src=file://" & Fname & "xx/px"
s = "xHTMLxxBODYx" & s & "xHTMLxxBODYx"
.HTMLBody = s
.Send 'or use .Display
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Last edited: