WCF Service Send Email On Outlook | Exception from HRESULT


I have created a WCF Project in .NET 4.5 to send emails from Outlook 2013 Or 2016 and host it on windows server 2012 and iis 8.

When run Service from Visual studio 2019 in windows 10 everything works as expected but when deployed to:

  • IIS 8 in windows server 2012

...the following error happens:

System.UnauthorizedAccessException: 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)). at Service.Method

I also did DCOM Config that I found solution from other posts but still I have same problem.

i want attach meeting and reminder in email , for this i used outlook .(outlook connected to Exchange) . if there is other way please say it.

asked on Stack Overflow Dec 8, 2019 by AhmadR3zA • edited Dec 8, 2019 by MickyD

1 Answer


No Office app, Outlook included, can be used fro ma Windows service. Extended MAPI (C++ or Outlook) can be, but that means a profile would either need to be manually configured first, or you would need to programmatically build it first. In case of C#, you can use the RDO family of objects in Redemption (it wraps the Extended MAPI system).

If you are only sending messages, why not use straight SMTP? If you are sending through an Exchange Server, why not use EWS (whcih has a .Net wrapper)

User contributions licensed under CC BY-SA 3.0