New line in macro message body vba

lokeshsu

Board Regular
Joined
Mar 11, 2010
Messages
178
Hi all,

I am using a excel macro to send message from excel and i have the code to send the mail, but the body of the mail is coming in a single line but i need to send it in different lines, how to do that.

Thanks
Lokesh
 

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Break your string down with vbCrLf

Code:
strBody = "Hello" & vbCrLf & "This is on a new line"

.Body = strBody
 
Upvote 0
Break your string down with vbCrLf

Code:
strBody = "Hello" & vbCrLf & "This is on a new line"

.Body = strBody
This is not working i tried this in the code

Code:
With OutMail        .To = "email@email.com"
        .BCC = ""
        .Subject = " Report for Report for the last interval " & Range("C9").Value & "."
        .HTMLBody = "Hi All, " & vbCrLf & "Please Find Attached the RTM Report for Process for the last interval " & Range("C9").Value & "." & RangetoHTML(rng) & "Regards," & Chr(10) & "name" & Chr(10) & Chr(10)
        .Display
        .Send
    End With
above is the code which i used
 
Upvote 0
you can use
HTML:
"<br/>"
with & after line where you want to have a new line since you are using
Code:
.htmlbody
.

Cheers!!
 
Upvote 0
How can you ensure a new line if your .htmlbody comes from a defined cell where there are new lines actually in the text?
 
Upvote 0

Forum statistics

Threads
1,215,583
Messages
6,125,661
Members
449,247
Latest member
wingedshoes

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