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.Outl开发者_开发问答ookAddin.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.
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
精彩评论