开发者

How to detect whether Outlook digitally signs an email by default?

开发者 https://www.devze.com 2023-01-09 00:06 出处:网络
Background: I\'m working on an Outlook addin which adds an attachment to outgoing emails. Support is required for all versions of Outlook.

Background: I'm working on an Outlook addin which adds an attachment to outgoing emails. Support is required for all versions of Outlook.

When a MailItem has been signed with a digital signature, adding an attachment to this mailItem generally fails unless you save the mail item. This removes the signature from mailitem. To me, this is so开发者_Python百科mewhat expected behaviour. Nothing weird here.

The problem is when the user turns digital signatures on (whether through the UI or as a Outlook default behavior) and then turns it off again. The MailItem is no longer signed but it still behaves as if it is -- we're unable to add an attachment to this email.

I found a newsgroup post which might explain why; it appears that objects retrieved through the outlook API aren't the actual objects.

http://www.tech-archive.net/Archive/Development/microsoft.public.win32.programmer.messaging/2006-02/msg00000.html

At the moment, I've given up trying to fix this problem nicely; saving the MailItem to a temporary file appears to fix this however for performance reasons we'd like to only save when a MailItem has transitioned from signed to unsigned. Another acceptable alternative is to detect whether digital signatures has been enabled by default or not. Though there is a registry entry related to the default setting of a digital signature, it is merely a suggestion and does not reflect accurately whether the email would have been signed by default or not.

Any ideas?


You can use redemption api library to call that method from C#.

Also have you tried creating a PInvoke signature from the extended mapi dll?


Turns out that you can use EMAPI in C++ to call IMessagePtr->SaveChanges(), which seems to work quite nicely. Unfortunately, you can't access this in C#.

0

精彩评论

暂无评论...
验证码 换一张
取 消