28

I am subscribed to an email account using Exchange Web Services 2007 and processing attachments as new emails come in. I would like to mark those emails as "read" on the server after I'm done processing them, but I'm finding it's not as simple as setting the "IsRead" property to true. I've even tried the following:

Dim msg As EmailMessage
msg.Load(New PropertySet({EmailMessageSchema.IsRead}))
msg.IsRead = True

I tried this after finding out that I had to load specific schema properties if I wanted to interact with certain parts of the message (like attachments). I've also tried directly binding the message to a new object and loading additional properties:

Dim iID as ItemId = msg.Id
Dim tmpMsg as EmailMessage = EmailMessage.Bind(service, iID, New PropertySet(BasePropertySet.FirstClassProperties, EmailMessageSchema.IsRead))
tmpMsg.IsRead = True

I'm getting no luck. I've googled around and found one MSDN blog example that seems like it should work, but he's got some classes that I can't seem to find (like the Microsoft.Exchange.WebServices.SetItemFieldType class; all I've got in the WebServices namespace are the Data and AutoDiscover namespaces, no classes or anything). And since I can't find those classes or anything similar I'm kinda stuck. He also listed a DAV example but, again, his code uses classes I can't find in my version of the EWS dll (which is 14.0.0.0). I tried downloading the latest API from Microsoft but that seemed to be the same version as what I already have.

So my question is, is there a way of marking an item as read using Exchange 2007 Web Services?

2 Answers 2

38

You need to call the tmpMsg.Update method to persist changes back to the server.

0
0

EmailMessage.Update() must be called before using EmailMessage.Move() as that creates a new item with a new id and deletes the original.

2
  • I think it is an answer, but to the question I googled to get here, not the question asked. Hence the desire to include it as a comment. The difference between this and other answers is mentioning it must be used before other common operations, something not mentioned elsewhere (except in a comment on this answer ) Commented Oct 27, 2021 at 12:48
  • Thanks for explaining the difference (excuse me for lacking actual technical insight). If you edit to put that into the answer body and could "bend" the answer to be answering the question at the top (while still providing the same info), then I assume that we have a useful answer contribution. (Sorry, I still won't upvote then, but I guess those who do have the technical understanding might then upvote.) Have fun, good luck.
    – Yunnosch
    Commented Oct 27, 2021 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.