StringBuilder

S

shapper

Hello,

I am creating the body of a mail message to be sent using
StringBuilder:

StringBuilder body = new StringBuilder();
body.AppendFormat("{0},", userName);
body.AppendLine();
body.AppendLine();
body.AppendLine("How are you?");

How should I create empty lines? User various ApendLine as n the
previous example or maybe using <br />:

StringBuilder body = new StringBuilder();
body.AppendFormat("{0},<br/><br/>", userName);
body.AppendLine("How are you?");

or maybe some other way?

Thanks,

Miguel
 
S

shapper

[...]
How should I create empty lines? User various ApendLine as n the
previous example or maybe using <br />:
    StringBuilder body = new StringBuilder();
    body.AppendFormat("{0},<br/><br/>", userName);
    body.AppendLine("How are you?");

I don't understand the above example.  .NET doesn't do anything special 
with HTML elements.  So appending "<br/>" doesn't insert line-breaks into  
your string.

AppendLine() should be fine, or you can append the Environment.NewLine  
character.

Pete

But if I am sending the email Html format won't I get the line breaks
by using <br/> in my string?
Basically, at the end I do: myMail.Body = body.ToString();

I've also read the following:
http://www.systemnetmail.com/faq/4.8.aspx

So I think I have two options:
1. Create an HTML page that contains the email body and send it ...
I think this would be more useful for complex mail bodies like
Newsletters.
2. Use StringBuilder to create the email body and include the needed
HTML tags as <p>, <br/>, etc ...

And if I send a No Html format email I could use:
body.AppendFormat("{0},\n\n", userName);

instead of:
body.AppendFormat("{0},<br/><br/>", userName);

Or not?

Just trying to find the correct way to create the body of Html mail
messages and Non Html mail messages.

Thanks,
Miguel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top