S22 imap从office365取邮件

时间:2017-01-18 12:44:40

标签: email ssl office365 imap

我正在使用s22.Imap referance从服务器获取新邮件。阅读交换服务器一切都很完美。但我们被转移到了办公室365。现在我无法从我的项目中读取新邮件。这是小代码。

using (ImapClient client = new ImapClient("outlook.office365.com", 993, user, pass, AuthMethod.Login, true)) {

   // Returns a collection of identifiers of all mails matching the specified search criteria.
   IEnumerable<uint> uids = client.Search(SearchCondition.New());

   // Download mail messages from the default mailbox.
   IEnumerable<MailMessage> messages = client.GetMessages(uids);

   foreach (MailMessage item in messages) { blablabla }

此部分返回此错误:The stream could not be read.

最后我在windows服务应用程序中使用此代码。所以我不是很清楚。

有人帮助我吗?

2 个答案:

答案 0 :(得分:0)

Office365不支持AuthMethod.Login。尝试使用AuthMethod.Plain或尝试使用其他IMAP库,例如我的MailKit库,这些库会更积极地维护。

希望有所帮助。

答案 1 :(得分:0)

它可能但我认为帐户的嫌疑人应该是 在线交流,而不是经典的嫌疑人

我对S22库也这样做,但我们要求更改邮件配置以接受imap连接