Search code examples
c#outlookms-officevsto

Outlook Change MessageClass digital signed Mail


I am working on a project, which displays a customicon and an informationarea in Outlook 2010 for special messages. To achive this, I change the MessageClass of the message. This works great, aslong as the message isn't digitally signed.
Here is the code to change the MessageClass:

        public static void SetMessageClass(ref Outlook.MailItem mi) {
        try {
            if (mi.MessageClass.ToLower() == "ipm.note" || mi.MessageClass.ToLower() == "ipm.note.smime" || mi.MessageClass.ToLower() == "ipm.note.myclass") {
                Logger.Log("Setze Message-Class auf " + MESSAGE_CLASS);
                mi.MessageClass = MESSAGE_CLASS;
                mi.Save();
            }
        } catch (System.Exception ex) {
            Logger.Log("Fehler beim setzen der Message-Class:\r\n" + ex.Message);
        }
    }

I need to change the MessageClass, because I want to display an icon and an informationarea.

If the mail has a digital signature, the following window appears: http://social.msdn.microsoft.com/Forums/getfile/186575

It doesn't matter which button I click, the icon doesn't changes.

Can anyone help me?

Greets Knerd

PS: Here is the question in german: http://social.msdn.microsoft.com/Forums/de-DE/vstode/thread/e51b221e-89f6-419f-90e6-e17c74662a9f


Solution

  • Outlook goes to great lengths to represent signed/encrypted message as regular "IPM.Note" MailItem objects (which they are not).

    The only workaround I know is to bypass the OOM layer either using Extended MAPI (C++ or Delphi) or Redemption (I am its author - any language) - use RDOSession.GetItemFromID in Redemption. You can then read the MessageClass/PR_MESSAGE_CLASS property and bypass signed/encrypted messages.