Thanks for the quick reply John.....
So...becuase I'm trying to generate an HTML email should I be trying to
include a new line like this?
body += "<strong>First Name:</strong>" + dr["FIRSTNAME"] + "<BR>\n";
....is that what you mean by adding carriage returns to the string?
On a side note, if I used this:
StringBuilder builder = new StringBuilder();
builder.Append("<strong>First Name:</strong>" + dr["FIRSTNAME"] + "<BR>";
msg.Body = builder.ToString();
SmtpServer.Send(msg);
would that accomplish what I'm trying to do with this large string?
Thanks again for your help.
John.
"John Timney (ASP.NET MVP)" wrote:
I believe the max size of a string in .NET is 2147483647 characters,
although you would be mad to use a string of this size when you could use
stringbuilder which is optimized for large string handling.
This type of restriction normally occurs because your mail server imposes a
restriction on the length of individual lines in a message body. The SMTP
specifications suggests 76 characters per line, so ideally you'll need to
add carriage returns into your string at these lenghts.
--
Regards
John Timney
ASP.NET MVP
Microsoft Regional Director
"John Scott" <jo*******@despammed.com> wrote in message
news:B7**********************************@microsof t.com... Hi There.
I have a small c# problem. I am trying to create a dynamic email body.
The body may be larger than the maximum number of characters a string can have
(256?). I build the string like this:
private void SendEmail()
{
string body = "";
foreach(row in a dataset)
{
body += "First Name: " + dr["FNAME"].ToString();
body += "Last Name: " + dr["LNAME"].ToString();
....a number of different fields to follow.....
body +=" <br><hr>";//add some divider and go to the next record
}
MailMessage msg = new MailMessage();
msg.Body = body; //add the generated text to the email body
SmtpServer smtpServer = new SmtpServer();
smtpServer.Send(msg);
}
Now the email gets sent without any problems, but the body of the email is
cut-off after a certain number of characters.
How can I create an email body that can grow the way I need it to?
Thanks in advance.
Thanks,
John Scott.