简体   繁体   中英

How to download unread email attachment using Exchange web service in ASP.NET?

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM