none
The specified object was not found in the store while accessing mailbox RRS feed

  • Question

  • I have a windows service which uses Microsoft.Exchange.WebServices.dll version "14.03.0032.000" for reading emails from a particular mailbox. I get the following error logged sometimes even though the emails are properly read and deleted. please let me know what could be the issue.

    --start error details--------------

    The specified object was not found in the store.
    Type Microsoft.Exchange.WebServices.Data.ServiceResponseException
    Module Microsoft.Exchange.WebServices
    Method ServiceResponse.InternalThrowIfNecessary(...)
    StackTrace

    at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary() at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute() at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalBindToItems(IEnumerable`1 itemIds, PropertySet propertySet, ServiceErrorHandling errorHandling) at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToItem(ItemId itemId, PropertySet propertySet) at Microsoft.Exchange.WebServices.Data.ExchangeService.BindToItem[TItem](ItemId itemId, PropertySet propertySet) at CT.Shared.MailboxMonitors.EWSProvider.FetchEmailList(Boolean fetchBody, Boolean fetchHeader) at CT.Shared.MailboxMonitors.MailboxMonitor.__processMailbox() at CT.Shared.MailboxMonitors.MailboxMonitor.__monitor()

    --end error details---------------

    ------following code fetches the emails------------

     public override IEnumerable<EmailMessage> FetchEmailList(bool fetchBody, bool fetchHeader)
            {
                ItemView itemView = __getPropertyNames(fetchBody, fetchHeader);
                FindItemsResults<Item> findResults = __service.FindItems(WellKnownFolderName.Inbox, itemView);

                List<CT.Shared.MailboxMonitors.EmailMessage> lstSearchResults = new List<CT.Shared.MailboxMonitors.EmailMessage>();

                for (int i = 0; i < findResults.Items.Count; i++)
                {
                    if (findResults.Items[i] is Microsoft.Exchange.WebServices.Data.EmailMessage)
                    {
                        //Bind to an existing message using its unique identifier.
                        Microsoft.Exchange.WebServices.Data.EmailMessage message = Microsoft.Exchange.WebServices.Data.EmailMessage.Bind(__service, findResults.Items[i].Id);

                        CT.Shared.MailboxMonitors.EmailMessage emailMessage = new CT.Shared.MailboxMonitors.EmailMessage();

                        emailMessage.MessageURL = message.Id.UniqueId;
                        emailMessage.MessageId = message.Id.ChangeKey;
                        emailMessage.ReceivedDate = message.DateTimeReceived;

                        emailMessage.EmailSubject = message.Subject;

                        if (message.Sender != null)
                        {
                            emailMessage.EmailFrom = message.Sender.Address;
                        }

                        if (message.ReceivedBy != null)
                        {
                            emailMessage.EmailTo = message.ReceivedBy.Address;
                        }

                        if (fetchBody && message.Body != null)
                        {
                            emailMessage.EmailBody = message.Body.Text;
                        }

                        if (fetchHeader && message.InternetMessageHeaders != null)
                        {
                            StringBuilder emailHeader = new StringBuilder();

                            foreach (InternetMessageHeader internetMsgHeader in message.InternetMessageHeaders)
                            {
                                emailHeader.AppendLine(internetMsgHeader.ToString());
                            }

                            emailMessage.EmailHeader = emailHeader.ToString();
                        }

                        lstSearchResults.Add(emailMessage);
                    }
                }

                return lstSearchResults;
            }

            private ItemView __getPropertyNames(bool fetchEmailBody, bool fetchHeader)
            {
                //find the first 10 messages
                ItemView itemView = new ItemView(CONST_EmailFetchRange);
                itemView.PropertySet = new PropertySet(BasePropertySet.FirstClassProperties);

                itemView.PropertySet.Add(ItemSchema.Id);
                itemView.PropertySet.Add(ItemSchema.DateTimeReceived);
                itemView.PropertySet.Add(ItemSchema.Subject);

                itemView.PropertySet.Add(EmailMessageSchema.InternetMessageId);
                itemView.PropertySet.Add(EmailMessageSchema.Sender);
                itemView.PropertySet.Add(EmailMessageSchema.ReceivedBy);

                itemView.OrderBy.Add(ItemSchema.DateTimeReceived, Microsoft.Exchange.WebServices.Data.SortDirection.Ascending);

                return itemView;
            }

    Wednesday, July 25, 2012 5:27 PM

All replies

  • Hi,

    does it make a difference to use a newer version of the Exchange Managed API, e.g. 1.2.1 or 2.0:

    Best,

    Frank

    Monday, February 18, 2013 11:12 PM