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 somewhat 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.
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?