I am trying to update an application that uses WebDAV for Exchange 2003 to return responseXML, then creates cases in SalesForce CRM (using the wsdl web service) and puts the attachments from the letters in the files.
We are migrating to Exchange 2010 SP2, so I need to access my inbox using EWS.
I get a ServiceResponseException error . The specified object was not found in the repository.
Here is my code:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
List<SearchFilter> searchFilterCollection = new List<SearchFilter>();
searchFilterCollection.Add(new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.IsRead, false)));
searchFilterCollection.Add(new SearchFilter.SearchFilterCollection(LogicalOperator.And, new SearchFilter.IsEqualTo(EmailMessageSchema.HasAttachments,true)));
SearchFilter searchFilter = new SearchFilter.SearchFilterCollection(LogicalOperator.Or, searchFilterCollection.ToArray());
Mailbox mb = new Mailbox(@"bbtest@domain");
ItemView view = new ItemView(1);
FolderId fid = new FolderId(WellKnownFolderName.Inbox, mb);
service.Url = new Uri("https://domain/EWS/Exchange.asmx");
Microsoft.Exchange.WebServices.Data.Folder inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(service, fid);
FindItemsResults<Item> results = service.FindItems(WellKnownFolderName.Inbox, searchFilter, view);
foreach (EmailMessage email in results)
{
Debug.Print(email.From.ToString());
Debug.Print(email.DisplayTo);
Debug.Print(email.Subject);
}
it produces an error in this line:
Microsoft.Exchange.WebServices.Data.Folder inbox = Microsoft.Exchange.WebServices.Data.Folder.Bind(service, fid);
What am I doing wrong and how can I fix this, please?
Also, is there no way to force EWS to return a similar XML response stream as webDAV?