Hi
Apologies if this has been asked elsewhere.
I have the following code:
Sub SendMorningEmails()
With Application
.EnableEvents = False
End With
Dim TempFilePath As String
Set appOutlook = CreateObject("outlook.application")
Set Message = appOutlook.CreateItem(olMailItem)
With Message
.Subject = "Reservation Volumes"
.HTMLbody = "<p style=font-family:calibri;font-size:14.5>" & "Dear All" & "<br>" & "<br>"
'This section creates an image as a PNG file to embed in the body of the email, the type of image can be altered by changing this designation, ie, to .jpg in the code below
ThisWorkbook.Activate
Sheet31.Visible = True
Sheet31.Activate
Set Plage = Sheet31.Range("F62:O127")
Plage.CopyPicture
With ThisWorkbook.Worksheets("Morning Emails").ChartObjects.Add(Plage.Left, Plage.Top, Plage.Width, Plage.Height)
.Activate
.Chart.Paste
.Chart.Export Environ$("temp") & "\" & "MEmailFile" & ".png", "PNG"
End With
Sheet31.ChartObjects(Sheet31.ChartObjects.Count).Delete
Set Plage = Nothing
'This section attaches the embedded image with a Position at 0 to makes the attachment hidden
TempFilePath = Environ$("temp") & "\"
.Attachments.Add TempFilePath & "MEmailFile.png", olByValue, 0
'This section adds an html <img src=''> link to this image
'Using the "<br>" fucntion and the text within the speech marks this section adds the signature to the email
.HTMLbody = .HTMLbody _
& "<img src='cid:MEmailFile.png'" _
& "<br>" & "Kind regards" _
& "<br>" & "<br>" & "<B>Rich Thornton</B>" _
& "<br>" & "Marketing Executive - Mortgages" _
& "<br>" & "<br>" & "01793 653009" & "<br>" & "<br>" _
& "<B><font-family:calibri;font-size:14.5><font color=red>Please treat this e-mail and any accompanying documentation as confidential.</font></B>" & "</p>"
.To = Sheet33.Cells(5, 2)
.Cc = ""
.Display
End With
With Application
.EnableEvents = True
End With
End Sub
Which until today worked fine, however when it runs it brings up a runtime 1004 error at the highlighted line. I've tried all I know but can't get it to work. As mentioned is worked fine until today which is odd I feel!
Thanks in advance
Bookmarks