如何检测 Outlook 是否默认对电子邮件进行数字签名?
背景: 我正在开发一个 Outlook 插件,它将附件添加到外发电子邮件中。所有版本的 Outlook 都需要支持。
当邮件项目已使用数字签名进行签名时,向该邮件项目添加附件通常会失败,除非您保存该邮件项目。这将从邮件项目中删除签名。对我来说,这在某种程度上是预期的行为。这里没什么奇怪的。
问题是当用户打开数字签名(无论是通过 UI 还是作为 Outlook 默认行为)然后再次将其关闭时。 MailItem 不再经过签名,但其行为仍然像经过签名一样 — 我们无法向此电子邮件添加附件。
我发现一个新闻组帖子可以解释原因;通过 Outlook API 检索的对象似乎不是实际对象。
目前,我已经放弃尝试很好地解决这个问题;将 MailItem 保存到临时文件似乎可以解决此问题,但是出于性能原因,我们希望仅在 MailItem 从签名转换为未签名时保存。另一种可接受的替代方法是检测默认情况下是否启用了数字签名。尽管有一个与数字签名的默认设置相关的注册表项,但这只是一个建议,并不能准确反映电子邮件是否会默认签名。
有什么想法吗?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以使用 兑换 api 库 从 C# 调用该方法。
您还尝试过从扩展的mapi dll 创建PInvoke 签名吗?
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?
事实证明,您可以在 C++ 中使用 EMAPI 来调用 IMessagePtr->SaveChanges(),这似乎工作得很好。不幸的是,您无法在 C# 中访问它。
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#.