1

Here i have a message string that displays the content of an email. I would like the From, The subject and the body to all display on a new line.

Could someone please advise on how this is done. Below is what i'm trying but its all still on one line.

I thought enviroment.newline would work, i still think it will but maby im doing it wrong?

MessageString = "From: " + message.Headers.From.Address + Environment.NewLine + "Subject: " + message.Headers.Subject + Environment.NewLine + "Body: " + messagePart.BodyEncoding.GetString(messagePart.Body);

if you could also show me how to write code over multiple lines and still have it function that would be awesome too???????


4

2 回答 2

2

If email is in html format then try <br />

于 2012-05-03T09:48:06.647 回答
0

You can also use a Literal control with Mode set to PassThrough, and then use <br /> for a line break. Literals (and I guess also labels) HTML-encode their content, so a <br /> is not rendered as a line break by default.

However, be careful: You have to avoid XSS attacks on your own this way! The HttpUtility.HtmlEncode method is useful therefor.

于 2012-05-03T09:53:13.713 回答