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 attac开发者_C百科hment.
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
精彩评论