【问题标题】:Imap cyrillic mailImap 西里尔文邮件
【发布时间】:2012-10-08 19:32:59
【问题描述】:

我使用 mailsystem.NET 库将消息放入我的收件箱。这是我的代码:

Imap4Client imap = new Imap4Client();
imap.ConnectSsl("imap.gmail.com", 993);
imap.Login(mylogin, mypassword);
Mailbox mails;
mails = imap.SelectMailbox("INBOX");
Message commomMessage = new Message();
commomMessage.From = new Address("someAddress", "someName");
commomMessage.To.Add(mylogin, "myName");
commomMessage.Subject = "someSubject";
commomMessage.BodyHtml.Text = "Привет мир";//or some cyrillic text 
commomMessage.Date = DateTime.Now;
mails.Append(commomMessage);

当我打开我的 gmail 收件箱时,我看到了这封邮件,但正文包含 ????? ??? 而不是“привет мир”。如果commomMessage.BodyHtml.Text 只包含拉丁字符,则没有问题。

【问题讨论】:

标签: c# .net gmail imap gmail-imap


【解决方案1】:

如果Message 类继承自.NET 的MailMessage 类,请尝试使用它的BodyEncoding 属性并将其设置为System.Text.Encoding.UTF8,例如:

commomMessage.BodyEncoding =  System.Text.Encoding.UTF8;

如果Message 类没有从MailMessage 继承,请尝试寻找其他方法为您的电子邮件设置适当的编码。我相信这是您可以通过使用 UTF8 编码来解决的问题。

【讨论】:

  • Message 类不继承自 .NET 的 MailMessage 类。
  • 他有 charset 属性,但是当我将它设置为 "utf-8" 时什么也没发生
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2012-12-27
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多