japanese email subject encoding

后端 未结 9 1527
天命终不由人
天命终不由人 2020-12-15 08:02

Aparently, encoding japanese emails is somewhat challenging, which I am slowly discovering myself. In case there are any experts (even those with limited experience will do)

9条回答
  •  庸人自扰
    2020-12-15 08:53

    Here's what I use to send Japanese emails. Subject line looks fine in Outlook 2010, gmail and on iPhone.

    Encoding encoding = Encoding.GetEncoding("iso-2022-jp");
    byte[] bytes  = encoding.GetBytes(subject);
    string uuEncoded = Convert.ToBase64String(bytes);
    subject = "=?iso-2022-jp?B?" + uuEncoded + "?=";
    
    // not sure this is actually necessary...
    mailMessage.SubjectEncoding = Encoding.GetEncoding("iso-2022-jp");
    

提交回复
热议问题