We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Sub SendPdfInvoice() 'send pdf invoice Sheets("invoice").Select Range("MailBody").Select Dim MailToAdress As String MailToAdress = Range("MailTo").Value Dim MailBccAdress As String MailCcAdress = Range("MailCc").Value Dim MailSubject As String MailSubject = Range("MailSubject").Value ' creates and sends a new e-mail message with Outlook Dim OLF As Outlook.MAPIFolder, olMailItem As Outlook.MailItem Dim ToContact As Outlook.Recipient Set OLF = GetObject("", _ "Outlook.Application").GetNamespace("MAPI").GetDefaultFolder(olFolderInbox) Set olMailItem = OLF.Items.Add ' creates a new e-mail message With olMailItem .Subject = Range("MailSubject").Value ' message subject 'Set ToContact = .Recipients.Add("firstname.lastname@example.org") ' add a recipient Set ToContact = .Recipients.Add(Range("MailTo")) ' add a recipient Set ToContact = .Recipients.Add(MailCcAddress) ' add a recipient ToContact.Type = olCC ' set latest recipient as CC .Body = "Also this text I would like to replace with the range in the excel sheet named MailBody instead of writing it here" & Chr(13) ' the message text with a line break .Attachments.Add Range("PdfPath").Value, olByValue, , _ "Attachment" ' insert attachment .OriginatorDeliveryReportRequested = False ' delivery confirmation .ReadReceiptRequested = False ' read confirmation .Send ' sends the e-mail message (puts it in the Outbox) End With Set ToContact = Nothing Set olMailItem = Nothing Set OLF = Nothing End Sub
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
Join the community of 500,000 technology professionals and ask your questions.