Sending Email via VBA - Carriage Return Not Working in Messagebody (1 Viewer)

sgtSortor

Registered User.
Local time
Today, 13:30
Joined
Mar 23, 2008
Messages
31
I am sending an email from a button, and it runs a word merge and then attaches that word document and two others two an email. All that works fine, but in the body of the email the carriage return is not working.

I've tried "vbCrLf", "Chr(13)" and "Chr(10)". but none of them are working in this email. I use vbCrLf all of the time in many other emails and it works fine. Not sure what's going on here.

Code:
Public Function SendEmailFinancial()
Dim MessageBody, vAttach1, vAttach2, vAttach3, vTo
Dim appOutLook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutLook = CreateObject("Outlook.application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
With MailOutLook

'==============================
'This code automatically sends the email to whoever with as many attachments as you want.
'2/10/2010 - kls.
vTo = Forms!frmhold.ProjMgrEmailHold
MessageBody = ""
vAttach1 = "Z:\_GRANT FORMS\3_Agreement\Financial Forms\A-19Merged.docx"
vAttach2 = "Z:\_GRANT FORMS\3_Agreement\Financial Forms\statewide vendor registration.doc"
vAttach3 = "Z:\_GRANT FORMS\3_Agreement\Financial Forms\w9.doc"

    
MessageBody = "" & vbCr & vbCr
MessageBody = MessageBody & "Project ID:  " & "" & Forms!frmhold.ProjectIDHold & vbCrLf
MessageBody = MessageBody & "Project Title:  " & "" & Forms!frmhold.ProjectTitleHold & vbCrLf
MessageBody = MessageBody & "Program Manager: " & " " & Forms!frmhold.ProjMgrHold & vbCrLf & vbCrLf
MessageBody = MessageBody & "I am attaching three (3) forms that are needed in order for the State of Washington to " & vbCrLf
MessageBody = MessageBody & "process grant payments for your organization for the purposes of carrying out the activities outlined in your final approved application." & vbCrLf & vbCrLf
.BodyFormat = olFormatHTML
.To = "ceni235; catc235"
.Subject = "SHIP Financial Forms for Grant #" & "" & Forms!frmhold.ProjectIDHold
.HTMLBody = MessageBody
.Attachments.Add vAttach1, 1
.Attachments.Add vAttach2, 1
.Attachments.Add vAttach3, 1
.Display
End With
End Function

This is what the email is looking like when it comes out:

Project ID: 2013YG00229 Project Title: Toolbox Talks Construction Safety Guides and Mobile App Program Manager: Shana Peschek I am attaching three (3) forms that are needed in order for the State of Washington to process grant payments for your organization for the purposes of carrying out the activities outlined in your final approved application.

Not sure what's going on here, any help would be appreciated.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 13:30
Joined
Aug 30, 2003
Messages
36,125
You're using HTML body, so you want to include <br> in the string instead of vbCrLf.
 

Users who are viewing this thread

Top Bottom