开发者

How to write the messages in the Email with two line spacess for each Message

开发者 https://www.devze.com 2023-01-20 20:22 出处:网络
message.Body = \"Message: \" + ex.Message +Environment.NewLine + \"Data:\"+ ex.Data + Environment.NewLine + \"S开发者_运维知识库tack Trace:\" + ex.StackTrace;
  message.Body = "Message: " + ex.Message +Environment.NewLine + "Data:"+ ex.Data 
                 + Environment.NewLine + "S开发者_运维知识库tack Trace:" + ex.StackTrace;

I am using Environment.NewLine., its going to next line perfectly but I need to put two line separated with ---------------- in between each message Data StackTrace.


Instead of Environment.NewLine, put:

"\n\r----------------\n\r"

You can store this in a const and then reuse:

const string Sep = "\n\r----------------\n\r";
message.Body = "Message: " + ex.Message + Sep + "Data:" + ex.Data 
                 + Sep + "Stack Trace:" + ex.StackTrace;

NB: \n\r produces a new line and a carriage return.

To reuse the code in a confirmation page, for example, replace the "\n\r" with

"<br />"


u can try "<br/> ------------------"

u can write html tags in message body but not in the title

0

精彩评论

暂无评论...
验证码 换一张
取 消