Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. problem with System.Web.Mail.MailMessage (html format)

problem with System.Web.Mail.MailMessage (html format)

Scheduled Pinned Locked Moved C#
questionhtmlcomhelpannouncement
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • N Offline
    N Offline
    Nathan Ridley
    wrote on last edited by
    #1

    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]

    B 1 Reply Last reply
    0
    • N Nathan Ridley

      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]

      B Offline
      B Offline
      benjymous
      wrote on last edited by
      #2

      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!

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups