brianfosterblack
Active Member
- Joined
- Nov 1, 2011
- Messages
- 251
I use outlook 365 and it is set to compose my emails in HTML with no special stationery being used.
Below is the VBA I use to send emails from my workbook.
When this email is generated the email does not include my signature, set up for that email account.
Is there a way to embed this into the mail.
Below is the VBA I use to send emails from my workbook.
When this email is generated the email does not include my signature, set up for that email account.
Is there a way to embed this into the mail.
VBA Code:
Sub EmailAttachmentsSelf()
Dim emailApplication As Object
Dim emailItem As Object
Set emailApplication = CreateObject("Outlook.Application")
Set emailItem = emailApplication.CreateItem(0)
wsName = "Reports"
Sheets("Reports").PageSetup.PrintArea = "ReportsPrint"
' save the file as pdf
ActiveSheet.ExportAsFixedFormat Type:=xlTypePDF, Filename:= _
ThisWorkbook.Path & "\" & "Reports " & Range("Master!B7").Value & ".pdf", Quality:=xlQualityStandard, IncludeDocProperties:=True, IgnorePrintAreas:=False, OpenAfterPublish:=False
Sheets(wsName).Select
' Now we build the email.
emailItem.To = Range("Master!B9").Value
emailItem.Subject = "Report " & Range("Master!B7").Value & " " & Date
emailItem.Body = "Attached is the tasks report for" & vbCr & vbCr & _
Range("Master!B7").Value & vbCr & vbCr & _
"as at the date and time of" & vbCr & vbCr & _
CDate(Now)
' Attach any file from your computer.
emailItem.Attachments.Add (ThisWorkbook.Path & "\" & "Reports " & Range("Master!B7").Value & ".pdf")
' Send the Email
On Error Resume Next
emailItem.Send
Set emailItem = Nothing
Set emailApplication = Nothing
If Range("Reports!J1").Value = 1 Then
Range("Reports!H3").Value = CDate(Now)
Else
Range("Reports!I3").Value = CDate(Now)
End If
MsgBox ("Mail is in your Outbox, ready to be sent to yourself")
End Sub