Read Email in VB.NET / ASP.NET



Now, after trying to use EWS as an alternative I've been getting this new error message that I can't seem to fix :

DTD is prohibited in this XML document.

And yes I've given these code a try :

  1. Dim settings As XmlReaderSettings = New XmlReaderSettings()
  2. settings.XmlResolver = Nothing
  3. settings.DtdProcessing = DtdProcessing.Parse
  4. settings.ValidationType = ValidationType.DTD
  5. Dim reader As XmlReader = XmlReader.Create(".xml", settings)

But it made no difference. Please Help!!

For your information : I'm trying to make this to run in a web based version

My code works perfectly during execution to read email using VB.NET.

Unfortunately this happen :

"Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))"

Additional Info:

  1. I'm a company worker = email I want to retrieve is using company domain (eg:

  2. Windows 10

  3. Microsoft Outlook 2016

  4. Visual Studio 2012

  5. .NET framework 4.5.1 & 4.5.2

  6. I code it using Microsoft.Office.Interop

I've searched google for solution on how to handle the problem and so far no luck.

  1. I've tried modifying DCOM
  2. I want to download new security update from, but no luck with the company internet restriction

Please help. I've been stuck for almost a month on this problem
asked on Stack Overflow Mar 27, 2019 by Lydia • edited Apr 11, 2019 by Lydia

1 Answer


Most likely this happens if Outlook and your app are running in different security contexts (e.g. one app is running as an admin). Try to close Outlook before starting your app - if that works, you have mismatched security context.

Also keep in mind that Office apps (including Outlook) cannot run in a service (such as IIS).

User contributions licensed under CC BY-SA 3.0