Text Format

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I am using StringBuilder to create a newsletter in Plain Text format.

1. How can I append an empty line? Something like:
Line 1

Line 2

2. Can I include an url in an email in plain text format? For example:
http://groups.google.com

3. Can I use tags? I think I can use tags but only the following:
Bold - <b>
Italic - <i>
Underline - <u>

Thank You,
Miguel
 
You cannot use tags in plain-text format. To create an empty line, you can
use "\r\n\r\n" or AppendLine().
 
Hello,

I am using StringBuilder to create a newsletter in Plain Text format.

1. How can I append an empty line? Something like:
    Line 1

    Line 2

It's \r\n according to the RFC.
2. Can I include an url in an email in plain text format? For example:
   http://groups.google.com

Well you obviously can include a raw URL, and any decent user agent
will actually detect it on its own and display it as a link. No tags
though,
3. Can I use tags? I think I can use tags but only the following:
    Bold - <b>
    Italic - <i>
    Underline - <u>

No. "Plain text" means just that, plain text. No formatting. There are
some conventions (_abc_ for underline, *abc* for bold, /abc/ for
italic), and some user agents even format text accordingly (e.g.
Mozilla), but that's far from universal.
 
1. You can use 'System.Environment.NewLine' two times to append an empty line.

2.Yes you can include an email in the plaintext format
 
shapper said:
Hello,

I am using StringBuilder to create a newsletter in Plain Text format.

1. How can I append an empty line? Something like:
Line 1

Line 2

2. Can I include an url in an email in plain text format? For example:
http://groups.google.com

3. Can I use tags? I think I can use tags but only the following:
Bold - <b>
Italic - <i>
Underline - <u>

You might like to use StringWriter instead. With StringWriter:

sw.WriteLine("Line1");
sw.WriteLine();
sw.WriteLine("Line2");

You can use underlining StringBuilder by calling sw.GetStringBuilder()
in case you need to remove or insert text.
 
You might like to use StringWriter instead. With StringWriter:

sw.WriteLine("Line1");
sw.WriteLine();
sw.WriteLine("Line2");

You can use underlining StringBuilder by calling sw.GetStringBuilder()
in case you need to remove or insert text.

What is the difference between StringBuilder and StringWriter?
I was on the impression that I should always use StringBuilder.

And if I use StringWriter why should I convert it to StringBuilder
after it?
Shouldn't I just convert it ToString and just assign it to the email
body?

Thanks,
Miguel
 
What is the difference between StringBuilder and StringWriter?
I was on the impression that I should always use StringBuilder.

And if I use StringWriter why should I convert it to StringBuilder
after it?
Shouldn't I just convert it ToString and just assign it to the email
body?

Thanks,
Miguel

And one more question: can I define the text font used?

I believe I can't and I think the default in emails clients for plain
text emails is usually Courier New ... Just confirming.

Thanks,
Miguel
 
What is the difference between StringBuilder and StringWriter?
I was on the impression that I should always use StringBuilder.

And if I use StringWriter why should I convert it to StringBuilder
after it?
Shouldn't I just convert it ToString and just assign it to the email
body?

Thanks,
Miguel

I was reading and I found this formatting:

New Line - "\n"
Padding Char - '.'
Tab = "\t"

Is this correct?

Why "\r\n"?
 
And one more question: can I define the text font used?

Only in a formatted e-mail.
I believe I can't and I think the default in emails clients for plain
text emails is usually Courier New ... Just confirming.

Normally, but it's up to the individual.
 
I was reading and I found this formatting:

New Line - "\n"
Padding Char - '.'
Tab = "\t"

Is this correct?

Why "\r\n"?

Reading what?

The format of plain text email messages is defined by RFC822 (http://
www.faqs.org/rfcs/rfc822.html). It specifically defines a newline as
sequence CR LF, which is "\r\n" in C#.

For the same reason, you should be careful when using
StringWriter.WriteLine() - it uses Environment.NewLine to terminate
lines, which is "\r\n" on Windows, but may be different elsewhere, so
you introduce a potential portability problem there.
 
Back
Top