Email Pivot Table Chart

Skybluekid

Well-known Member
Joined
Apr 17, 2012
Messages
1,231
Office Version
  1. 365
Platform
  1. 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
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
Well, then debug that line. Use Debug.Print. What is the evaluated file name for instance? Simplify the line till you get no error.
 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top