Note that there are some explanatory texts on larger screens.

plurals
  1. POerror reading oulook using MAPI in ASP.NET
    text
    copied!<p>I use VS2010, C#, ASP.NET to read outlook email. I've setup outlook express 6 with my gmail (IMAP), I get a strange exception at the first line, where my COM object is being created, here is my code:</p> <pre><code>Microsoft.Office.Interop.Outlook.Application app = null; Microsoft.Office.Interop.Outlook._NameSpace ns = null; Microsoft.Office.Interop.Outlook.PostItem item = null; Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null; Microsoft.Office.Interop.Outlook.MAPIFolder subFolder = null; try { app = new Microsoft.Office.Interop.Outlook.Application(); ns = app.GetNamespace("MAPI"); ns.Logon("gmail_id", "gmail_pass", false, true); inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); subFolder = inboxFolder.Folders["MySubFolderName"]; //folder.Folders[1]; also works Console.WriteLine("Folder Name: {0}, EntryId: {1}", subFolder.Name, subFolder.EntryID); Console.WriteLine("Num Items: {0}", subFolder.Items.Count.ToString()); for (int i = 1; i &lt;= subFolder.Items.Count; i++) { item = (Microsoft.Office.Interop.Outlook.PostItem)subFolder.Items[i]; Console.WriteLine("Item: {0}", i.ToString()); Console.WriteLine("Subject: {0}", item.Subject); Console.WriteLine("Sent: {0} {1}", item.SentOn.ToLongDateString(), item.SentOn.ToLongTimeString()); Console.WriteLine("Categories: {0}", item.Categories); Console.WriteLine("Body: {0}", item.Body); Console.WriteLine("HTMLBody: {0}", item.HTMLBody); } } catch (System.Runtime.InteropServices.COMException ex) { } finally { ns = null; app = null; inboxFolder = null; } </code></pre> <p>it is my exception:</p> <pre><code>Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). </code></pre> <p>this exception is create at the first line:</p> <pre><code>app = new Microsoft.Office.Interop.Outlook.Application(); </code></pre> <p>I've used <code>Microsoft.Office.Interop.Outlook.dll</code> file as my interop reference, what is going wrong here? I can read my Gmail inbox in outlook express 6, but I have no luck in my ASP.NET web app</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload