1

I wrote following code to delete all the user properties of all the mails in folder -inbox. When I was stepping through the code, there were no any exceptions. Delete() and Save() methods were executed properly.

Then after, when I was checking for user properties using the outlook design mode still I was able to see the user property, it had not deleted. (see the picture)

enter image description here

Can you please explain what's going on here? Any mistakes in the code?

            //Test
            InboxFolder = outlookNs.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
            items = InboxFolder.Items;
            foreach (object mailitem in items)
            {
                olMail = mailitem as Outlook.MailItem;
                if (olMail != null)
                {
                    Outlook.UserProperty upK = olMail.UserProperties["Processed"];
                    if (upK != null)
                        upK.Delete();
                    olMail.Save();
                }
            }
            //Test
Kushan Randima
  • 2,174
  • 5
  • 31
  • 58

0 Answers0