Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.MailItem' RRS feed

  • Question

  • Getting Error:

    Unable to cast COM object of type 'System.__ComObject' to interface type 'Microsoft.Office.Interop.Outlook.MailItem'. This operation failed because the QueryInterface call on the COM component for the interface with IID '{00063034-0000-0000-C000-000000000046}' failed due to the following error: No such interface supported (Exception from HRESULT: 0x80004002 (E_NOINTERFACE)).

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using System.Runtime.InteropServices;
    using Outlook = Microsoft.Office.Interop.Outlook;
    using Microsoft.Office.Interop.Outlook;
    using System.Collections;

    namespace Demo2
        public partial class ThisAddIn
            Outlook.MailItem mailItem;
            Outlook.Items items;
            private void ThisAddIn_Startup(object sender, System.EventArgs e)

                Outlook.NameSpace ns = this.Application.Session;
                Outlook.MAPIFolder inbox = ns.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);           
                items = inbox.Items;          
                items.ItemChange += new ItemsEvents_ItemChangeEventHandler(items_ItemChange);

            void items_ItemChange(object Item)
                Outlook.MailItem mail = (Outlook.MailItem)Item;(AT This Point Getting Error!!!)

                if (Item != null)

                    Outlook.MailItem mailItem = (Outlook.MailItem)Item;
                    string emailAdress = mailItem.SenderEmailAddress;
                    MessageBox.Show("Email id is " + emailAdress);



    • Edited by NirajZ Tuesday, October 9, 2012 9:07 AM
    • Moved by Jason Dot Wang Friday, October 12, 2012 5:51 AM This thread is about Outlook for Developer (From:Visual C# General)
    Tuesday, October 9, 2012 9:05 AM


All replies