【发布时间】:2015-06-03 03:33:57
【问题描述】:
我在使用 S22.IMAP 库获取 Microsoft Exchange 电子邮件服务器的新邮件通知方面需要帮助。我已成功获得 gmail 的新邮件通知,以及 Microsoft Exchange 电子邮件 S22.IMAP 没有抛出新邮件通知。
当我打印 gmail 和 Microsoft Exchange 的客户端功能时,我得到以下信息:
如何获得 Microsoft Exchange 电子邮件的新邮件通知?
using System;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Net.Mail;
using S22.Imap;
namespace Test {
class Program {
static void Main(string[] args)
{
//For gmail I'm getting the new mail notification
//using (ImapClient Client = new ImapClient("imap.gmail.com", 993,
// "login", "password", AuthMethod.Login, true))
//For Microsoft exchange email I'm not getting new mail notification, even though it supports "IDLE"
using (ImapClient Client = new ImapClient("mail.exchangeglobal.com", 993,
"login", "password", AuthMethod.Login, true))
{
// Should ensure IDLE is actually supported by the server
if(Client.Supports("IDLE") == false) {
Console.WriteLine("Server does not support IMAP IDLE");
return;
}
Client.NewMessage += OnNewMessage;
// Put calling thread to sleep. This is just so the example program does
// not immediately exit.
System.Threading.Thread.Sleep(6000000);
}
}
static void OnNewMessage(object sender, IdleMessageEventArgs e)
{
Console.WriteLine("A new message arrived. Message has UID: "+
e.MessageUID);
//Fetch the new message's headers and print the subject line
MailMessage m = e.Client.GetMessage( e.MessageUID, FetchOptions.HeadersOnly );
Console.WriteLine("New message's subject: " + m.Subject);
}
}
}
【问题讨论】:
-
也有同样的问题。似乎是 S22.imap 问题,因为 Outlook 通知与其他解决方案配合得很好
标签: gmail exchange-server imap