如何在 ASP.NET 中使用 Exchange Web 服务下载未读电子邮件附件?

发布于 2024-12-04 15:41:06 字数 499 浏览 0 评论 0原文

我正在使用 Exchange Server 2007 SP3

,并且我能够使用以下代码连接 Exchange Web 服务

ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.RequestServerVersionValue = new RequestServerVersion();
esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
esb.Credentials = new NetworkCredential("<user_id>", "<password>", "<domain>");
esb.Url = @"https://<server_fqdn>/ews/Exchange.asmx";

我正在寻找下载未读附件的代码。

请你帮助我好吗?

I am using Exchange Server 2007 SP3

and I am able to connect exchange web service using following code

ExchangeServiceBinding esb = new ExchangeServiceBinding();
esb.RequestServerVersionValue = new RequestServerVersion();
esb.RequestServerVersionValue.Version = ExchangeVersionType.Exchange2007_SP1;
esb.Credentials = new NetworkCredential("<user_id>", "<password>", "<domain>");
esb.Url = @"https://<server_fqdn>/ews/Exchange.asmx";

I am looking for code to download unread attachment.

Could you please help me?

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

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

发布评论

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

评论(1

弥枳 2024-12-11 15:41:06

我发现了这一点:

private static void ProcessItems(ExchangeService exchangeService)
{
    var offset = 0;
    const int pageSize = 100;

    FindItemsResults<Item> result;

    do
    {
        var view = new ItemView(pageSize, offset)
        {
            SearchFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)
        };

        result = exchangeService.FindItems(WellKnownFolderName.Inbox, view);

        foreach (var item in result)
        {
            ProcessItem(item);
        }

        offset += pageSize;
    } while (result.MoreAvailable);
}

然后从方法 ProcessItem 你可以做任何你想做的事情,比如下载附件等等......

来源:使用 EWS 托管 API 处理 Exchange 文件夹中的项目

I have found this:

private static void ProcessItems(ExchangeService exchangeService)
{
    var offset = 0;
    const int pageSize = 100;

    FindItemsResults<Item> result;

    do
    {
        var view = new ItemView(pageSize, offset)
        {
            SearchFilter = new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)
        };

        result = exchangeService.FindItems(WellKnownFolderName.Inbox, view);

        foreach (var item in result)
        {
            ProcessItem(item);
        }

        offset += pageSize;
    } while (result.MoreAvailable);
}

then from the method ProcessItem you do whatever you want to do like download attachments and so on...

source: Processing items in an Exchange folder using EWS Managed API

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