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
nmail.Body = i.bDesc + System.Environment.NewLine + MsgBody.Text ;
nmail.Body = i.bDesc + "\r\n" + MsgBody.Text;
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.
This should work.
nmail.Body = i.bDesc + "\r\n" + MsgBody.Text;
Or...
nmail.Body = String.Format("{0}\r\n{1}",i.bDesc,MsgBody.Text);
精彩评论