locked
"[E2010] [EWSMA] [C#] [Windows]: Item.IsNew not behaving as expected RRS feed

  • Question

  • Hi,

    It appears as if the Item.IsNew property isn't quite behaving as described in the documentation, which is causing an issue for me.

    In the documentation (http://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.item.isnew(v=exchg.80).aspx) it says: "Gets a value that indicates whether this object is a real store item or a local object that has yet to be saved."

    So I would expect IsNew to return true for a new EmailMessage until it has been saved to a folder (to me, this is what the above statement is implying).

    However, sending the email using item.Send() also seems to cause the IsNew flag to false.

    This means I have no actual way of identifying whether the item has really been saved to a folder or not. And this is an issue because I also need to save the email out as an eml file (whether the email was sent or not), but this only appears to work once its been saved! (Specifically, to save the email as an eml file, I need to load the mime content, but this throws an "Object not found in store" exception if the email hasn't been saved).

    Since I can't rely on the IsNew property, I seem to be in a bit of a catch-22.

    Any way around this?

    Friday, May 2, 2014 12:24 PM

All replies

  • Further frustration:

    If I always just try and save the item before trying to load the mime content using

    Item.Save()

    then I get a message "This operation can't be performed because this service object already has an ID. To update this service object, use the Update() method instead".

    But if I use

    Item.Update(ConflictResolutionMode)

    instead, then get the message "This object was not found in the store".

    Argh!

    Friday, May 2, 2014 1:30 PM
  • Hi,

    what happened follows the documentation for the Item.IsNew property.

    When an item is sent, it is also saved into the SentItems system folder. So, you can not say that is new (it exists in the store).

    Regards,


    Désiré GOVIN Refresh IT Solutions

    Friday, May 2, 2014 2:10 PM
  • I do not believe this is true. Sending an item by calling Send() does not automatically put it into he SentItems folder. That only happens if you use SendAndSave(). And since I am not using that - only Send() - this is causing me the issue noted in my original post.

    Friday, May 9, 2014 10:49 AM