0
votes

I am trying to modify a Mailitem's category. First, I set

mail.Categories = ""; mail.Save();

Then at some later point, I set the following:

mail.Categories = "Red Category"; mail.Save();

This works most of the time, but sometimes the old category is stale in the messages pane, while the category displayed in the message is correct. If I right-click, only the Red Category is applied as it should. Is there a reason I am experiencing this inconsistency?

enter image description here

1
Does it work if you select a different message and the select the problematic one again?Dmitry Streblechenko
No, it does not. It is only resolved if I close Outlook and re-open. This seems to only happen on emails I've copied over from an IMAP account and dropped into this Exchange account.jkamdjou
That means Outlook is caching he messages. Where does mail variable come from? Do you always release it as soon as you are done using Marshal.ReleaseComObject?Dmitry Streblechenko

1 Answers

0
votes

Sometimes you need to refresh the view in Outlook by switching to another folder or re-opening an inspector window if you make changes through the Outlook object model.

For explorer windows you may set the CurrentFolder which allows to set a Folder object that represents the current folder displayed in the explorer.

For inspector windows you may close it, release the item shown in the inspector window and then re-open an item by using the EntryID value. See the NameSpace.GetItemFromID method which returns a Microsoft Outlook item identified by the specified entry ID (if valid). Sometimes just re-opening an inspector window helps.