Answered by:
vb.net Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.MailItem

Question
-
Hello All,
Who can help me with a problem that i have right now.
I am trying to create a prog that will archive mails. I am using VS 2008 and MS outlook 2003.
The prog is crashing at this point:
Dim I As Integer
For i = 1 To oItems.Count
omsg = oItems.Item(I) **** I will receive the error in the subject at this point.
If omsg.FlagStatus = OlFlagStatus.olFlagComplete Then
DT.Rows.Add(omsg.Subject)
End If
Next
I hope that I have posted my question in the correct forum.
Regards,
DO.- Moved by Karel ZikmundMicrosoft employee Friday, February 5, 2010 5:33 PM Wrong forum (From:Building Development and Diagnostic Tools for .Net)
Friday, February 5, 2010 10:38 AM
Answers
-
Check out the Outlook API you use, you are casting a COM object to interface Microsoft.Office.Interop.Outlook.MailItem, which it doesn't implement. That's what the exception says.
Here are resources for Outlook APIs:
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/063a23a6-1595-4c83-a25f-6c94658c4649
-Karel- Proposed as answer by Karel ZikmundMicrosoft employee Tuesday, February 9, 2010 4:56 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Sunday, May 6, 2012 5:46 AM
Friday, February 5, 2010 5:30 PM -
Or ask in the Outlook dev forum: http://social.msdn.microsoft.com/Forums/en-US/outlookdev/threads
Thanks!
Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)
- Marked as answer by Ed Price - MSFTMicrosoft employee Monday, July 23, 2012 9:56 PM
Monday, July 23, 2012 9:56 PM
All replies
-
Check out the Outlook API you use, you are casting a COM object to interface Microsoft.Office.Interop.Outlook.MailItem, which it doesn't implement. That's what the exception says.
Here are resources for Outlook APIs:
http://social.msdn.microsoft.com/Forums/en-US/vsto/thread/063a23a6-1595-4c83-a25f-6c94658c4649
-Karel- Proposed as answer by Karel ZikmundMicrosoft employee Tuesday, February 9, 2010 4:56 PM
- Marked as answer by Ed Price - MSFTMicrosoft employee Sunday, May 6, 2012 5:46 AM
Friday, February 5, 2010 5:30 PM -
Hello Karel,
Thanks allot for your reply.
I will check it out.
Regards,
DO.Tuesday, February 9, 2010 11:17 AM -
Or ask in the Outlook dev forum: http://social.msdn.microsoft.com/Forums/en-US/outlookdev/threads
Thanks!
Ed Price (a.k.a User Ed), SQL Server Experience Program Manager (Blog, Twitter, Wiki)
- Marked as answer by Ed Price - MSFTMicrosoft employee Monday, July 23, 2012 9:56 PM
Monday, July 23, 2012 9:56 PM