c# EWS :when delete mail or move to recycle bin RRS feed

  • Question

  • Hi.

    I'm using exchange server 2007.

    Connection work fine, i read perfectly attachament, print them or not. but from yestarday, after 2 days that my application work i got some error and i hope that someone can help me.

    The error that i get is ...


    9/1/2011 7:11:10 AM

    Microsoft.Exchange.WebServices.Data.ServiceResponseException: The specified object was not found in the store.
       at Microsoft.Exchange.WebServices.Data.ServiceResponse.InternalThrowIfNecessary()
       at Microsoft.Exchange.WebServices.Data.MultiResponseServiceRequest`1.Execute()
       at Microsoft.Exchange.WebServices.Data.ExchangeService.InternalDeleteItems(IEnumerable`1 itemIds, DeleteMode deleteMode, Nullable`1 sendCancellationsMode, Nullable`1 affectedTaskOccurrences, ServiceErrorHandling errorHandling)
       at Microsoft.Exchange.WebServices.Data.ExchangeService.DeleteItem(ItemId itemId, DeleteMode deleteMode, Nullable`1 sendCancellationsMode, Nullable`1 affectedTaskOccurrences)
       at Microsoft.Exchange.WebServices.Data.Item.InternalDelete(DeleteMode deleteMode, Nullable`1 sendCancellationsMode, Nullable`1 affectedTaskOccurrences)
       at ExchangeBranjeMailov.ReadingMailovService.Reading()

    I work with two ways.
    One is if i get mail from specific xxxx@something.xom, those mail are moved instantly in to Folder inside recycle bin.

    The all other mail are deleted in to recycle bin, normaly and i print attachament.

    The code is like this:


    FindItemsResults<Item> findResults = prijava.FindItems(WellKnownFolderName.Inbox, new ItemView(int.MaxValue));
        foreach (Item item in findResults.Items)
         EmailMessage email = EmailMessage.Bind(_loGon, item.Id, new PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.Attachments));
         if (email.From.Address.ToUpper().Contains("@MARICIO")) 
          FolderView _Folders = new FolderView(int.MaxValue);
          Mape.PropertySet = new PropertySet(BasePropertySet.IdOnly);
          SearchFilter SF = new SearchFilter.IsGreaterThan(FolderSchema.TotalCount, 0);
          _Folders.Traversal = FolderTraversal.Shallow;
          FindFoldersResults fFR = prijava.FindFolders(WellKnownFolderName.DeletedItems, SF, _Folders);
           if (fFR.Folders[0].DisplayName.ToString() == "Something") //Something is childfolder in recycle bin
            //all mail from i move in to childfolder
          catch (Exception Napaka)
           System.IO.File.AppendAllText(@"D:\tmp\Error\log.txt", DateTime.Now.ToString() + " " + Napaka.ToString() + "\r\n");
          if (email.HasAttachments && email.Attachments[0] is FileAttachment)
           FileAttachment priponka = (FileAttachment)email.Attachments[0];
           string strAttach = System.IO.Path.GetExtension(@"D:\tmp\" + priponka.Name).ToUpper() == ".HTML" ? @"D:\tmp\" + System.IO.Path.GetFileNameWithoutExtension(priponka.Name) + ".DOC" : @"D:\tmp\" + priponka.Name;
           switch (System.IO.Path.GetExtension(strAttach).ToUpper())
            case ".PDF":
            case ".JPG":
            case ".JPE":
            case ".BMP":
            case ".GIF":
            case ".PNG":
            case ".JPEG":
            case ".TIF":
            case ".TIFF":
            case ".WMF":
            case ".DOC":
            case ".DOCX":

    Tnx for any reply.


    Thursday, September 1, 2011 6:21 AM

All replies

  • It was all my fault.

    I was testing on another computer, and when i reboot my test PC the service was startet on test PC. So windows service was running on both,production and on test.

    So, that was a problem.


    Tnx anyway.

    Thursday, September 1, 2011 10:15 AM