DarkW1nter
DarkW1nter

Reputation: 2861

email in .net - c#

this is probably an easy one, I just dont know what it is! Im trying to add the contents of a field from a query to the 1st line of an email in c#, then have a new line for the rest of the body.

nmail.Body = i.bDesc + MsgBody.Text;

So Id want to put the carriage return between i.bDesc and MsgBody.Text, Can anyone give me a nudge in the right direction?

thanks

Upvotes: 0

Views: 93

Answers (4)

WEFX
WEFX

Reputation: 8572

This should work.

nmail.Body = i.bDesc + "\r\n" + MsgBody.Text; 

Or...

nmail.Body = String.Format("{0}\r\n{1}",i.bDesc,MsgBody.Text);

Upvotes: 0

ScottE
ScottE

Reputation: 21630

You can use \r\n for a new line, which is the equivalent of VbCrLf in vb.net. Aducci has given a good cross-language answer.

Upvotes: 0

heisenberg
heisenberg

Reputation: 9759

nmail.Body = i.bDesc + "\r\n" + MsgBody.Text;

Upvotes: 0

Aducci
Aducci

Reputation: 26694

nmail.Body = i.bDesc + System.Environment.NewLine + MsgBody.Text ;

Upvotes: 6

Related Questions