在 Outlook 加载项中处理数字 ID/签名
我有一个 C# Outlook 加载项应用程序(VS2005 和 2003 Outlook),它读取传入的电子邮件并删除附件和电子邮件文本正文以供将来处理。有时我会收到一封包含数字签名的电子邮件。当我尝试访问 mailitem.body 属性时,应用程序将失败,并引发以下异常:
System.Runtime.InteropServices.COMException (0xAB404001):操作失败。 在 Microsoft.Office.Interop.Outlook._MailItem.get_Body() 在 MyLib.MyApp.OutlookAddin.MailProcessor.ProcessMailItem(MailItem mailItem)
我很确定这是导致问题的数字签名,因为如果我将电子邮件转发回自己,它将删除原始发件人的数字签名和附加信息在应用程序中将毫无问题地处理电子邮件。我不知道该怎么办。我需要处理该电子邮件,所以我不能忽略它。以某种方式获取原始电子邮件的正文而不引发异常将是理想的选择。或者我想如果我可以识别出与电子邮件相关的数字签名,我可以将电子邮件转发给自己,但这似乎有点混乱。有人有任何建议/修复吗?感谢您的任何帮助。
I have a C# Outlook Add-In application (VS2005 and 2003 Outlook) that reads incoming emails and strips out the attachments and the email text body for future processing. Occasionally I'll get an email that contains a digital signature. The application will fail when I try to access the mailitem.body property, throwing the following exception:
System.Runtime.InteropServices.COMException (0xAB404001): The operation failed.
at Microsoft.Office.Interop.Outlook._MailItem.get_Body()
at MyLib.MyApp.OutlookAddin.MailProcessor.ProcessMailItem(MailItem mailItem)
I'm pretty sure it is the digital signature causing the problem because if I forward the email back to myself, it will strip off the original sender's digital signature and the add-in application will process the email without any problems. I'm not sure what to do. I need to process the email, so I can't just ignore it. Somehow getting the body of the original email without throwing an exception would be ideal. Or I guess if I can identify that there is a digital signature associated with the email, I could forward the email to myself, but that seems a little messy. Does anyone have any suggestions/fixes? Thanks for any help.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
后续行动。我最终所做的是将 get_body 调用放入 try..catch 块中。如果出现错误,我会将电子邮件移至另一个 Outlook 文件夹以进行手动处理。以下是我在 Microsoft 论坛上发布的问题以及我收到的回复的链接。 http://social. msdn.microsoft.com/Forums/en-US/vsto/thread/d8b29cff-7656-4440-920a-21047c1ff82f
A followup. What I ended up doing was throwing the get_body call in a try..catch block. If there was an error, I moved the email to another Outlook folder for manual processing. Here is a link to the question that I posted on Microsoft's forum and a response that I received. http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/d8b29cff-7656-4440-920a-21047c1ff82f