i'm sending hebrew email 2 places, 1 gmail , other outlook.
the problem:
gmail working fine every time (they detect encoding automatically) outlook display body in gibberish, can fix if change display encoding hebrew(windows) unicode(utf-8) (when opening message display in outlook).
worth mention headers , subject fine.
the question: how can "tell" outlook or other program view mail unicode(utf-8) encoding ? without need manually.
i try set encoding, char-set , not can work.
code related:
public static void sendemail(mailmessage msg ) { contenttype mimetype = new system.net.mime.contenttype("text/html"); msg.alternateviews.add(system.net.mail.alternateview.createalternateviewfromstring(msg.body, mimetype)); smtpclient smtp = new smtpclient { host = "mailgw.netvision.net.il", port = 25, deliverymethod = smtpdeliverymethod.network, usedefaultcredentials = false, credentials = new networkcredential(uname,upass) }; smtp.send(msg); } here couple examples how tried play encoding:
msg.bodyencoding = encoding.ascii; msg.bodyencoding = encoding.utf8; msg.bodytransferencoding = transferencoding.sevenbit;
at end make work configuration of alternative view, this:
alternateview view = system.net.mail.alternateview.createalternateviewfromstring(msg.body, encoding.utf8, "text/html"); msg.alternateviews.add(view); as can see i've set mime (as did before) set encoding utf-8, solve problem.
Comments
Post a Comment