Search code examples
c#exchangewebservices

How to add a category to an email item


I am updating an old Outlook.Interop App that moves emails around, downloads attachments, and auto assigns categories to the emails that it moves. In the old app you could do something like...

email.Categories = "Blue Category";

That does not work in EWS. Does anyone have any ideas?

Thanks

I have tried:

email.Categories.Add("Blue Category");
email.Categories.Equals("Blue Category");

and obviously:

email.Categories = "Blue Category";

Solution

  • email.Categories.Add("Blue Category");
    

    is the way to do it you also need to call update on the Item for the change to be saved.I suggest you enable tracing https://learn.microsoft.com/en-us/exchange/client-developer/exchange-web-services/how-to-trace-requests-responses-to-troubleshoot-ews-managed-api-applications then you should be able to see if the update is being sent to the server. You can also see if the change has been applied by calling load on the Item after the update and see if the property on the Item has been updated on the server (as you may just be having a client cache issue).