Skybluekid
Well-known Member
- Joined
- Apr 17, 2012
- Messages
- 1,231
- Office Version
- 365
- Platform
- Windows
Hi
I am using the below code to email a Pivot Chart in the body of an email. I am getting a runtime 438 error. Any help would be appreciated.
Sub ChartMail()
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim Salu As String
Dim BodyText As String
Dim EndText As String
Dim Fnmae As String
Application.ScreenUpdating = False
Application.EnableEvents = False
'Define Text Strings
Salu = Sheet11.Range("S6").Value
BodyText = ""
EndText = ""
Fname = Path & Sheet11.Range("B3").Value & " June2018" & ".jpg"
'Save Graph
ActiveWorkbook.Sheet11.ChartsObjects("Chart 1").Chart.Export filename:=Fname, FilterName:="jpg"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Importance = 2
.To = Sheet11.Range("S4").Value
.CC = ""
.BCC = ""
.Subject = "Penalty Charge Statistics - " & Sheet11.Range("B3").Value
.HTMLBody = BodyText & "<img src = Fname>" & EndText
'.Send
.Display
End With
On Error GoTo 0
End Sub
I am using the below code to email a Pivot Chart in the body of an email. I am getting a runtime 438 error. Any help would be appreciated.
Sub ChartMail()
Dim TempFilePath As String
Dim TempFileName As String
Dim OutApp As Object
Dim OutMail As Object
Dim Salu As String
Dim BodyText As String
Dim EndText As String
Dim Fnmae As String
Application.ScreenUpdating = False
Application.EnableEvents = False
'Define Text Strings
Salu = Sheet11.Range("S6").Value
BodyText = ""
EndText = ""
Fname = Path & Sheet11.Range("B3").Value & " June2018" & ".jpg"
'Save Graph
ActiveWorkbook.Sheet11.ChartsObjects("Chart 1").Chart.Export filename:=Fname, FilterName:="jpg"
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
On Error Resume Next
With OutMail
.Importance = 2
.To = Sheet11.Range("S4").Value
.CC = ""
.BCC = ""
.Subject = "Penalty Charge Statistics - " & Sheet11.Range("B3").Value
.HTMLBody = BodyText & "<img src = Fname>" & EndText
'.Send
.Display
End With
On Error GoTo 0
End Sub