HTML Email

  • Thread starter Thread starter Thomas Heiz
  • Start date Start date
T

Thomas Heiz

I want to create a html email with c# and the class System.Web.Mail. The
assign html code is correct, but the produced email has a lot of strange
errors in the text.

there are ! in the text, spaces and new lines in the tags.

Is there any solution for this problem?
Thanks
Thomas
 
I would like to see some sample code.

We can not tell anything if we don't see the code.

Regards,
Lars-Inge Tønnessen
Siemens Medical - Norway
 
Here the C# code (.NET 1.1):

MailMessage msg = new MailMessage();
msg.From = sender;
msg.To = recipient;
msg.Headers.Add("Reply-To", _XMLHandler.getEmailData.sender);

// convert rtf 2 html and attach it as body to the mail and beautify it
string html = rtf2html.BeautifyHTML(rtf2html.ConvertRtf2Html(bodyFile),
_TDWidth);
msg.BodyFormat = MailFormat.Html;
msg.Body = html;

// attach enclosures
AttachEnclosuresToMail(msg);

// send mail
SmtpMail.Send(msg);

I convert a RTF document to a HTML document and add the result to the
msg.Body.

Thanks
Thomas Heiz

----- Original Message -----
From: "Lars-Inge Tønnessen (VJ# MVP)" <http://emailme.larsinge.com>
Newsgroups: microsoft.public.dotnet.languages.csharp
Sent: Monday, March 20, 2006 10:57 PM
Subject: Re: HTML Email
 
I had a similar problem.

The solution was to add some newlines ("\n") to my HTML text. If you format
a very long message as a single string with no line breaks in it, so mail
systems will mess with it during delivery and the result will be a corrupted
HTML message.

I updated my code to ensure that no line was longer than approximately 150
characters and the problem was resolved.

Hope this helps

Steve
 
Back
Top