StringBuilder to Text

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hello, I a m building an email message in a StringBuilder Object and then
using the StringBuilder ToString() method to get it to regular text. It
appears to me that when I place a "\n" into the Stringbuilder object that
when this is translated into text, I loose the page break. Is this true and
I doing something wrong?

I'm guessing that I could insert a special character into the StringBuilder
object and then use the string Replace() method to translate that special
character into a "\n" and perhaps this would work.

Just wondering why it does not work when I place that value into the
StringBuilder Object.

Thanks
 
How are you noticing that you loose the break? In what context is this
happening?
 
Have you considered using Environment.Newline instead of "\n"?

Example:

StringBuilder textBuilder = new StringBuilder(512);
textBuilder.Append("Dear John,");
textBuilder.Append(Environment.Newline)

Perhaps that will help.

carl
 
I am loosing the page break when I use the StringBuilder ToString() method
when I am formatting an email message. I will try the Environment.NewLine()
method and see if that retains the line break.
 
Does the StringBuilder cause the newline disappear, or is it something with
the mail component. What happens if you just set the
StringBuilder.ToString() to a variable and looked at it, is the newline
gone?
 
I assume you are using c?

If you pass "\n" you'll get newline > chr(10)
If you want "\n" you might consider to use "\\n"
(Outlook express mangels this for me, use slash twice)
 

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

Back
Top