views:

24

answers:

2
  message.Body = "Message: " + ex.Message +Environment.NewLine + "Data:"+ ex.Data 
                 + Environment.NewLine + "Stack 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.

A: 

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

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

Muhammad Adeel Zahid
Yes I tried but its still showing me <br/> in my result..
kumar
that is because you aren't displaying in a web page. To get the newline in an email, see my answer to this question.
awrigley
+2  A: 

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 />"
awrigley