Search code examples
exchangewebservices

fileAttachment.Load() not working for second attachment


I am getting "The specified object was not found in the store., The process failed to get the correct properties." error while loading the FileAttachment.

Here is my code

 foreach (Attachment attachment in message.Attachments)
                    {
                        if (attachment is FileAttachment)
                        {
                            if ( attachment.IsInline==true)
                            {
                                // in line image , may be part of signature image not considering for process 
                                continue;
                            }
                            else
                            {
                                FileAttachment fileAttachment = attachment as FileAttachment;
                                      string route1 = ConfigurationManager.AppSettings["route"];
                                      string route = route1 + fileAttachment.Name;
                                      String strFileUploadResut = "false";
                                      try
                                      { 
                                              fileAttachment.Load(route1 + fileAttachment.Name);
                                               FilenetFactory FileNetUploadUtil = new FilenetFactory();
                                              Console.WriteLine(" Sending File  " + fileAttachment.Name + " to OneScan webservice.");
}
catch (Exception E)
                                      {
                                          log.logText("Exception during sending to webservice.  "+ E.Message, "Info");
                                          if (E.Message.ToString() == "The specified object was not found in the store., The process failed to get the correct properties.")
                                          { }

For First attachment its load properly. for second attachment i am getting this error. Not sure why its work first time and throws exception second time. What wrong i am doing here? any advice !!


Solution

  • Sounds like it might be another process working on the same message, eg if another process has moved the message between your calls to the server then Id's you have will be invalid and that would be the error you would expect to receive from the server. A way to test that would be to try to load the message after you receive that error.