none
(EWS) Mail item not found on Exchange server using Item ID RRS feed

  • Question

  • I have an application that has been working fine for several weeks, basically it polls an Exchange 2010 mail server mailbox for new messages, gets the details of each one and any attachments, and use that information to create cases (with attachments) on the SalesForce CRM.

    After each case is created from the email, the email must be marked as **read** by retrieving it from Exchange using the stored Item ID and calling the property set.

    For several weeks this has been working fine, even getting some extra properties from Exchange such as the *Subject, From, To* properties which I can use in the session log.

    Suddenly today the mail isn't being returned by Exchange from the **itemID** if I try to include the **PropSet** - if I omit the PropSet it works fine.

    here is the code:

    try { //creates an object that will represent the desired mailbox Mailbox mb = new Mailbox(common.strInboxURL); // new Mailbox(targetEmailAddress); @bbtest@bocuk.local

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

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

    // As a best practice, limit the properties returned to only those that are required. PropertySet propSet = new PropertySet(BasePropertySet.IdOnly, ItemSchema.Subject, EmailMessageSchema.IsRead, EmailMessageSchema.Sender, EmailMessageSchema.DateTimeReceived);

    // Bind to the existing item by using the ItemId. // This method call results in a GetItem call to EWS. EmailMessage mail = EmailMessage.Bind(service, itemId); //, propSet);

    if (!mail.IsRead) // check that you don't update and create unneeded traffic { mail.IsRead = true; // mark as read mail.Update(ConflictResolutionMode.AutoResolve); // persist changes } mail.Update(ConflictResolutionMode.AlwaysOverwrite); e2cSessionLog("\tcommon.MarkAsRead", "email Item ID: " + itemId); //e2cSessionLog("\tcommon.MarkAsRead", "MARKED AS READ email Subject: " + mail.Subject.ToString() + "; From: " + mail.Sender.Name, mail.DateTimeReceived.ToString());


        ...

    notice that in the line `EmailMessage mail = EmailMessage.Bind(service, itemId); //, propSet);` I have now omitted the PropSet argument and it now works.

    But why?

    Is there something else I need to do in order to always get the properties back with the mail returned using Item ID?

    Any thoughts?


    Wednesday, May 14, 2014 1:40 PM

All replies

  • That should work okay, I would suggest you enable tracing and post a Trace of one of your requests and responses. That should better tell what's happening

    Cheers
    Glen

    Thursday, May 15, 2014 4:09 AM