Click here to Skip to main content
15,889,595 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
I am trying to read my Outlook 2010 inbox and all works good until I start reading my mail body

C#
MyOutlookItem = ((Microsoft.Office.Interop.Outlook.MailItem)myInbox.Items[ItemNo]);
...
string body = MyOutlookItem.Body


C#
'MyOutlookItem.Body threw an exception of type 'System.Runtime.InteropServices.COMException'


Can any one help me

Thanks in Advance

What I have tried:

All possible references are added
MyOutlookItem is checked for NULL
Posted
Updated 10-Mar-16 1:25am
v2
Comments
Maciej Los 9-Mar-16 17:06pm    
You should check if MyOutlookItem is null before...
BTW: What is exact error message?
thenewbee 10-Mar-16 5:10am    
Hi
Thanks for the reply.
MyOutlookItem is checked for null and its returning success for other properties like MyOutlookItem.Subject. But when try to access the mail body it fails.
The exact error is "Unspecified error (Exception from HRESULT: 0x80004005 (E_FAIL))"
Maciej Los 10-Mar-16 7:16am    
Full error message, please...

1 solution

Seems that isn't programming issue...

Such of error is displayed when the level of privileges in not enough. Please see: Error Reading Outlook Calendar Appointment with C# program - Stack Overflow[^]

[EDIT]
thenewbee[^] wrote:
But what confuses me is that I tried to access the same outlook folder from Ms Access and it successfully retrieved all mail body with no errors.
Is Access using another mechanism to access the folders?


Well, if this is not privileges issue... Check antivirus software: Reading email body crashes from Visual Basic[^]

Finally, i'd suggest to change BodyFormat[^] to "Plain Text" before you'll access to Body.
 
Share this answer
 
v2
Comments
thenewbee 10-Mar-16 10:05am    
Yes, I agree and I have seen that link.
But what confuses me is that I tried to access the same outlook folder from Ms Access and it successfully retrieved all mail body with no errors.
Is Access using another mechanism to access the folders?
Maciej Los 10-Mar-16 10:39am    
Wow! Very interesting observation. I can't reproduce your problem.
Have you tried to debug the programme?
thenewbee 10-Mar-16 11:06am    
Yes and verified that MyOutlookItem is not null. Only Body, htmlbody are not accessible

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900