ServiceResponseException: the specified object was not found in the repository

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);// .Exchange2007_SP1);

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());

//creates an object that will represent the desired mailbox
Mailbox mb = new Mailbox(@"bbtest@domain");

ItemView view = new ItemView(1);

//creates a folder object that will point to inbox folder
FolderId fid = new FolderId(WellKnownFolderName.Inbox, mb);

service.Url = new Uri("https://domain/EWS/Exchange.asmx");

//this will bind the mailbox you're looking for using your service instance
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?

+4
1

, NotFound , Exchange. , , , MB. ( , , , - , , .) , - , , , EWS default creds, , , .

, WebDAV EWS: , , , , WebDAV E2007.

+7

Source: https://habr.com/ru/post/1531206/


All Articles