exchange-server - 使用 Exchange 托管 api (EWS) 监控邮箱附件

标签 exchange-server ews-managed-api

我计划创建一个 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/

相关文章:

python - 将电子邮件标记为已读python

c# - Microsoft.Exchange.WebServices.Data.ServiceValidationException : The property RequiredAttendees can't be used in FindItem requests

c# - Exchange 401 未经授权

.net - 我们可以使用EWS托管API连接到Exchange 2016吗?

c# - 如何使用 Microsoft.Exchange.WebServices?

sharepoint - 将 SharePoint 警报发送到 Exchange 中的公用文件夹

python - 尝试使用 ExchangeLib 返回过去 24 小时内的电子邮件

exchangewebservices - EWS 托管 API - 如何将项目从一个邮箱复制到另一个邮箱

windows - 以编程方式处理新电子邮件和存储附件的最佳方式是什么

powershell - 检查 Powershell 中是否存在通讯组