我计划创建一个 Windows 服务,该服务将监视交换邮箱中具有特定主题的邮件。此类电子邮件的附件需要存储在网络共享上的特定文件夹中。我相信我可以使用 Exchange Web Services Managed API(使用 Exchange 2007 SP1)来实现这一点。
如果您有这方面的经验,请分享一些示例或链接,而不是下面的 MSDN 链接,这可以让我快速开始。
http://msdn.microsoft.com/en-us/library/dd633696%28v=EXCHG.80%29.aspx
最佳答案
假设这些邮件正在进入您 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>();
关于exchange-server - 使用 Exchange 托管 api (EWS) 监控邮箱附件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5654259/