Email from Excel

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.
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
 

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

Forum statistics

Threads
1,213,536
Messages
6,114,213
Members
448,554
Latest member
Gleisner2

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