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. Mail Encoding using MailMessage

Mail Encoding using MailMessage

Scheduled Pinned Locked Moved C#
csharpcomhelpquestion
1 Posts 1 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.
  • D Offline
    D Offline
    DAve
    wrote on last edited by
    #1

    Hi, I should first make it clear I know virtually nothing about c# & .NET (so please speak slowly and use short words:-D) I'm modifying a c# program someone else wrote which, as part of its process sends a mail using MailMessage. This works... However when the message arrives some (not all) of the new lines (CR,LF) are messed up. I noticed that if I open the mail in outlook and go View->Encoding this is set to "Western European (ISO)" if I switch this to "Western European (Windows)" the lines look right again. So I looked into this and noticed the BodyEncoding member, but still can't get this working. My code is MailMessage mail = new MailMessage(); mail.To = "me@somewhere.com"; mail.Cc = ""; mail.Bcc = ""; mail.From = "Someone@SomewhereElse.com"; mail.Body = <String read from a file somewhere>; SmtpMail.SmtpServer = "smtp.MyServer.com"; SmtpMail.Send( mail ); I have tried adding... mail.BodyEncoding = System.Text.Encoding.GetEncoding(1252); and mail.BodyEncoding = System.Text.Encoding.Default; but still the message is always displayed as "Western European (ISO)", does anyone have any idea how I can fix this? Cheers DAve

    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