Edwin
Edwin

Reputation: 1

How to use line breaks in VBA for an outlook email

I am trying to separate this messages as salutation, body, and signature using VBA in excel that will make an automatic outlook email. But I can't separate each one of them using line breaks. Care to help?

Dim MyOutlook As Object
Set MyOutlook = CreateObject("Outlook.Application")


Dim MyMail As Object
Set MyMail = MyOutlook.CreateItem(olMailItem)

MyMail.To = "[email protected]"
MyMail.CC = "[email protected]"enter code here
MyMail.Subject = "Sample Subject"
MyMail.Body = "Hello Team," & _
              "Please see attached for this month's summary" & _
              "Thanks!" & _
              "Sample Signature"
Attached_File = "C:\Users\public\Documents\sample_reports.xls"

MyMail.Attachments.Add Attached_File

MyMail.Send

End Sub

Upvotes: 0

Views: 772

Answers (1)

dms292
dms292

Reputation: 71

use vbNewLine

MyMail.Body =  "Hello Team," & vbNewLine & _
               "Please see attached for this month's summary" & vbNewLine & _
               "Thanks!" & vbNewLine & _
               "Sample Signature"

Upvotes: 1

Related Questions