-
Notifications
You must be signed in to change notification settings - Fork 7
Open
Description
Combining your code with suggestion by @ddavisso4, forcing NO signature for accounts that are not listed, also if they reply to a signed message, and forcing signature for listed accounts even if "sign" was already set to ON manually:
void OutlookApplication_ItemSend(object Item, ref bool Cancel)
{
// loop registry
foreach (string value in Registry.CurrentUser.OpenSubKey("SignatureManager").GetValueNames())
{
// check if current sender is set in registry to send signature
if (((Outlook.MailItem)Item).SendUsingAccount.DisplayName == value)
{
string PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003";
int currentSecurityFlags = ((Outlook.MailItem)Item).PropertyAccessor.GetProperty(PR_SECURITY_FLAGS);
int updatedSecurityFlags = currentSecurityFlags;
updatedSecurityFlags |= 1 << 0x1; // set bit 2 ON - forces signing
((Outlook.MailItem)Item).PropertyAccessor.SetProperty(PR_SECURITY_FLAGS, updatedSecurityFlags);
}
else
{
string PR_SECURITY_FLAGS = "http://schemas.microsoft.com/mapi/proptag/0x6E010003";
int currentSecurityFlags = ((Outlook.MailItem)Item).PropertyAccessor.GetProperty(PR_SECURITY_FLAGS);
int updatedSecurityFlags = currentSecurityFlags;
updatedSecurityFlags &= ~(1 << 0x1); // set bit 2 OFF - forces no signing
((Outlook.MailItem)Item).PropertyAccessor.SetProperty(PR_SECURITY_FLAGS, updatedSecurityFlags);
}
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels