c# - Fetch Outlook Calander Mails -


in inbox there calendar mail(meeting request calendar).when application fetching mail of calendar mail inbox throwing following error

unable cast com object of type 'system.__comobject' interface type 'microsoft.office.interop.outlook.mailitem'. operation failed because queryinterface call on com component interface iid '{00063034-0000-0000-c000-000000000046}' failed due following error: no such interface supported (exception hresult: 0x80004002 (e_nointerface)).

 public void getoutlookemails()       {                oapp = new outlook.application();               ons = oapp.getnamespace("mapi");                foreach (outlook.mapifolder folder in ons.folders)               {                   getfolders(folder);               }     }   public void getfolders(outlook.mapifolder folder)       {            if (folder.folders.count == 0)           {                try               {               if (folder.defaultitemtype == outlook.olitemtype.olmailitem)                       {                           if (folder.name == "inbox")                           {                               oemailsfolder = ons.getdefaultfolder(outlook.oldefaultfolders.olfolderinbox);                               outlook.items inboxitems = oemailsfolder.items;                                if (inboxitems.count > 0)                               {                                   foreach (outlook.mailitem mail in inboxitems)///when compiler comes here not create mail object , throws error...because email contains calander reminder gues need check if olcalander event or somthing else resolves error                                    {                                               if (mail != null)                                               {                                                  here retreiving concerning data emails///no issue here                                               }                                   }                               }                           }               }               catch (exception ex)               {                   throw ex;               }           }           else           {               foreach (outlook.mapifolder subfolder in folder.folders)               {                   getfolders(subfolder);               }           }        } 

the item casting may of different type - contactitem, appointmentitem, meetingitem, taskitem. check type , cast , use it.

https://msdn.microsoft.com/en-us/library/ms268994.aspx

-vimal


Comments

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -