Manage encryption and digital signature buttons in Outlook 2007 or later

I am working on a small script in VBA that will allow me to automatically forward messages, including encrypted ones.

The only problem I am facing is to remove the encryption programmatically.

I thought I could do it like this:

  • Open message
  • deselect encryption and sign options
  • message

With this approach, I do not know how to get a link to the Encrypt and Sign buttons.

Here is the code that works for standard, unencrypted emails. I set this method as an "email rule" for all incoming messages:

Sub test_macro(MyMail As MailItem)
    MyMail.Display
    'Need some API here to access the decrypt button    


    MyMail.Recipients.Add "otheraddress@company.com"
    MyMail.Recipients.Add "otheraddress2@company.com"
    Item_Send (MyMail)


End Sub

Background

. Outlook (2003/2007/2010/etc), , , ( , , ).

  • , - , , , . , Outlook, API ?

  • POP-, , . , , , / , Outlook .

? !

+5
3

IMAP, Mail.dll. - , !

0

, , , , VBA, , ( ) ( ). .NET

https://support2.microsoft.com/kb/2636465?wa=wsignin1.0

, #.NET Outlook 2007, 2010, 2013, , :

public static bool isEmailEncrypted(ref Outlook.MailItem mItem) {
        bool retVal = false;
        string PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003";
        long flags = (long)mItem.PropertyAccessor.GetProperty(PR_SECURITY_FLAGS);
        //need to do bitwise AND operation
        long bitwiseAND = flags & 1; //encrypted bit is the first bit
        if (bitwiseAND == 1) {
            retVal = true;
        }
        return retVal;
    }
+3

, MailItem, MailItem.Encrypt().

, : http://support.microsoft.com/?kbid=279013

, , , , , , MailItem .

0
source

All Articles