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