problem with System.Web.Mail.MailMessage (html format)
-
Hi, I'm having a problem with my mail sending code. The latest version of Outlook Express strips out my html and screws it all up, complaining of "potentially harmful" attachments, etc, rendering the final email ugly. It seems that by specifying HTML formatting, the MailMessage class is generating text and html formats of the message and attaching the html for people who have html support. How do I make it not try and be fancy and "helpful" in this way, and just format the whole email as html, like I want it to? When it tries to make a text version of the email, it ends up splitting long URLs over two lines, and then outlook screws them up. In trying to be more "functional", MailMessage is ending up being a pain in the butt.
public void Send() { MailMessage msg = new MailMessage(); string mailto = _recipients[0]; for(int i=1; i<_recipients.Count; i++) mailto += ";" + _recipients[i]; msg.To = mailto; msg.Subject = _subject; msg.From = _from; if(_useTemplate) { foreach(DictionaryEntry de in _keys) _body = _body.Replace(de.Key.ToString(), de.Value.ToString()); } msg.BodyFormat = _isHtml ? MailFormat.Html : MailFormat.Text; msg.Body = _body; SmtpMail.Send(msg); }
NATHAN RIDLEY Web Application Developer email: nathan @ netlab.com.au [remove the spaces before and after the @ symbol] -
Hi, I'm having a problem with my mail sending code. The latest version of Outlook Express strips out my html and screws it all up, complaining of "potentially harmful" attachments, etc, rendering the final email ugly. It seems that by specifying HTML formatting, the MailMessage class is generating text and html formats of the message and attaching the html for people who have html support. How do I make it not try and be fancy and "helpful" in this way, and just format the whole email as html, like I want it to? When it tries to make a text version of the email, it ends up splitting long URLs over two lines, and then outlook screws them up. In trying to be more "functional", MailMessage is ending up being a pain in the butt.
public void Send() { MailMessage msg = new MailMessage(); string mailto = _recipients[0]; for(int i=1; i<_recipients.Count; i++) mailto += ";" + _recipients[i]; msg.To = mailto; msg.Subject = _subject; msg.From = _from; if(_useTemplate) { foreach(DictionaryEntry de in _keys) _body = _body.Replace(de.Key.ToString(), de.Value.ToString()); } msg.BodyFormat = _isHtml ? MailFormat.Html : MailFormat.Text; msg.Body = _body; SmtpMail.Send(msg); }
NATHAN RIDLEY Web Application Developer email: nathan @ netlab.com.au [remove the spaces before and after the @ symbol]Not a direct answer, but be careful - some spam detection scripts/filters (certainly SpamAssassin) doesn't look too kindly on html-only email I guess the reasoning is if someone sends you an email and really wants you to view it as HTML, then you have to ask yourself what's hidden in that HTML that makes it so necessary for you to view it? -- Help me! I'm turning into a grapefruit! Phoenix Paint - back from DPaint's ashes!