Question

VijayAluvala on Mon, 18 Sep 2017 00:07:00


Hi,

I am trying to access outlook object and code is below.I created Virtual Directory and deployed the code in IIS.I am getting Access denied error when i try to access outlook object.

  myOutlook.Application application = null;

            try
            {
                if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
                {
                    application = Marshal.GetActiveObject("Outlook.Application") as myOutlook.Application;
                }

Please help me how to get access to outlookk object.

Thanks,

Vijay



Sponsored



Replies

cheong00 on Mon, 18 Sep 2017 01:33:40


Don't use Office Automation (i.e.: those COM object to manipulate MS Office programs) in web environment.

This is especially bad for Outlook, where it's operation is tightly coupled with "current user's profile" of the user running Outlook, and usually the web application runs under NetworkService/Application Identity context, so it'd create security complications (it's possible to adjust the security settings to allow it to run, but also note that Outlook can execute binaries so it's general a bad idea).

If your company uses Exchange 2010+, you should use Exchange Web Service (EWS) to access mailbox functionality instead.



Wendy Zang on Mon, 18 Sep 2017 08:10:21


Hi Vijay,

According to your question is more related to Outlook, I will move it to Outlook for Developers forum for suitable support.

This forum discuss and ask the C# programming language, IDE, libraries, samples and tools.

Best Regards,

Wendy

Chenchen Li on Tue, 19 Sep 2017 01:53:07


Hello Vijay,

As cheong said, Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment. For more information, please visit Considerations for server-side Automation of Office:

In addition to these issues, one of the following common errors may occur when you try to automate Office server-side:
  • The CreateObject function and the CoCreateInstance function return one of the following run-time error messages and cannot be started for Automation.
    Message 4
    E_ACCESSDENIED (0x80070005): Access denied

If you want to send mail, I would suggest you use SMTP. You could visit How to send email in ASP.NET C# to see different methods.

Regards,

Celeste