IMAP邮件斯拉夫 [英] Imap cyrillic mail

查看:205
本文介绍了IMAP邮件斯拉夫的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用的是mailsystem.NET库将消息在我的收件箱。这是我的code:

I use the mailsystem.NET library to put a message in my inbox. This is my code:

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 只包含拉丁字符,是没有问题的。

When I open my gmail inbox, I see this mail, but the body contains ????? ??? rather than "привет мир". If commomMessage.BodyHtml.Text contains only Latin characters, there is no problem.

推荐答案

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

If Message class inherits from .NET's MailMessage class try using it's BodyEncoding property and set it to System.Text.Encoding.UTF8, for example:

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

如果消息类不从 MailMessage 继承试图找到设置适当的编码的其他方式的电子邮件。我相信这是,你可以通过使用UTF8编码解决这个问题。

If Message class doesn't inherit from MailMessage try to find other way of setting the appropriate encoding for your e-mail message. I believe it's the issue that you can fix by using UTF8 encoding.

这篇关于IMAP邮件斯拉夫的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆