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

发布于 2024-10-31 22:51:47 字数 380 浏览 5 评论 0原文

我计划创建一个 Windows 服务来监视交换邮箱中特定主题的邮件。此类电子邮件的附件需要存储在网络共享上的特定文件夹中。我相信我可以使用 Exchange Web Services Managed API(使用 Exchange 2007 SP1)来实现此目的。

如果您有这方面的经验,请分享除下面的 MSDN 链接之外的一些示例或链接,这些示例或链接可以让我快速入门。

http://msdn.microsoft.com/en -us/library/dd633696%28v=EXCHG.80%29.aspx

I plan on creating a windows service that will monitor an exchange mailbox for mails with particular subject. The attachments from such emails need to be stored in a specific folder on the network share. I believe I can achieve this using Exchange Web Services Managed API (using Exchange 2007 SP1).

If you have experience with this, please share some samples or links other than the MSDN link below that can give me a jump start.

http://msdn.microsoft.com/en-us/library/dd633696%28v=EXCHG.80%29.aspx

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

短叹 2024-11-07 22:51:47

假设这些邮件将进入您 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>();

Lets say these mails are coming into your Inbox on X mailbox. You create a subscription to that folder like so

PullSubscription subscription = 
SomeExchangeService.SubscribeToPullNotifications(
new FolderId[]{ WellKnownFolderName.Inbox },1440,"",EventType.Created);
Subscriptions.Add(subscription);

Now you have to set a timer and check the pull notifs

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
                }
            }
        }
   }

I hope this helps...

UPDATE Due to email request

public static List<PullSubscriptionpublic static List<PullSubscription> Subscriptions = new List<PullSubscription>();> Subscriptions = new List<PullSubscription>();
忆伤 2024-11-07 22:51:47

考虑创建一个搜索文件夹来筛选消息。您只需在搜索文件夹中查找并处理邮件。

Consider creating a search folder to screen the messages. You will only need to look for, and process, messages in the search folder.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文