假设这些邮件正在进入您 X 邮箱的收件箱。您像这样创建对该文件夹的订阅
PullSubscription subscription =
SomeExchangeService.SubscribeToPullNotifications(
new FolderId[]{ WellKnownFolderName.Inbox },1440,"",EventType.Created);
Subscriptions.Add(subscription);
现在您必须设置一个计时器并检查拉取通知
static void Exchanger_Elapsed(object sender, ElapsedEventArgs e)
{
foreach (var pullSubscription in Subscriptions)
{
foreach (var itemEvent in pullSubscription.GetEvents().ItemEvents)
{
Item item = Item.Bind(SomeExchangeService, itemEvent.ItemId);
if (item.Subject == someString)
{
// item.Attachments do something
// As in read it as a stream and write it
// to a file according to mime type and file extension
}
}
}
}
我希望这有帮助...
更新由于电子邮件请求
public static List<PullSubscriptionpublic static List<PullSubscription> Subscriptions = new List<PullSubscription>();> Subscriptions = new List<PullSubscription>();