Hi all,
Im trying to send an email of a report with the image attached in the body.
I've got it working but people are having issues when reading the html on their phones so I need it to be an image.
I've tried googling and getting help but I cant get anything
The image is located Sheets("Product compliance").Range("B2:w121")
Any help would be much appreciated. Im pretty green with vba.
Cheers
Ben
Sub email()
'send out the email
Dim Rng As Range, rnga As Range, rngb As Range, rngc As Range
Dim OutApp As Object
Dim OutMail As Object
Dim signature As String
Dim tstamp As String
' report location
Set Rng = Nothing
Set Rng = Sheets("Product compliance").Range("B2:w121")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
' Subject location
tstamp = Sheets("Save and Send").Range("D5")
With OutMail
.Display
End With
signature = OutMail.HTMLBody
' change change email list here
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = tstamp
.HTMLBody = RangetoHTML(Rng) & _
vbNewLine & signature
.Attachments.Add Sheets("Save and Send").Range("D4") & Sheets("Save and Send").Range("D23") ' attaching the pdf
'.Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub
Im trying to send an email of a report with the image attached in the body.
I've got it working but people are having issues when reading the html on their phones so I need it to be an image.
I've tried googling and getting help but I cant get anything
The image is located Sheets("Product compliance").Range("B2:w121")
Any help would be much appreciated. Im pretty green with vba.
Cheers
Ben
Sub email()
'send out the email
Dim Rng As Range, rnga As Range, rngb As Range, rngc As Range
Dim OutApp As Object
Dim OutMail As Object
Dim signature As String
Dim tstamp As String
' report location
Set Rng = Nothing
Set Rng = Sheets("Product compliance").Range("B2:w121")
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)
' Subject location
tstamp = Sheets("Save and Send").Range("D5")
With OutMail
.Display
End With
signature = OutMail.HTMLBody
' change change email list here
On Error Resume Next
With OutMail
.To = ""
.CC = ""
.BCC = ""
.Subject = tstamp
.HTMLBody = RangetoHTML(Rng) & _
vbNewLine & signature
.Attachments.Add Sheets("Save and Send").Range("D4") & Sheets("Save and Send").Range("D23") ' attaching the pdf
'.Display
End With
On Error GoTo 0
With Application
.EnableEvents = True
.ScreenUpdating = True
End With
Set OutMail = Nothing
Set OutApp = Nothing
End Sub