On button click outlook window doesn't open - c#

I have a button on my asp.net page when I click on it it should open an outlook window but i get the following error.
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154.
I'm using in my c# page:
using Microsoft.Office.Interop.Outlook;// Version 12.0.0
In Web.Config:
<add assembly="Microsoft.Office.Interop.Outlook, Version=12.0.0.0, Culture=neutral, PublicKeyToken=71E9BCE111E9429C"/>
It gives an error at this line:
Updated code as per request, I am just trying to open new instance.
Application oApp = new Application();
_MailItem oMailItem = (_MailItem)oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
Just FYI, When I run it on my pc it's working ok, but on the live environment it gives me this error.
and if the problem with IIS how can I solve it
thanks in advance.

I think you want to open email client window on the client where the web browser is running and not on the server machine where IIS is running.
If so, you can simply use mailto links. It will open a outlook window if outlook is installed on the client machine.

Related

System.Diagnostics.Process.Start causes error "No application is associated with the specified file for this operation" when deployed

I am new to c# and have created a web form using ASP.NET 4.7.2 and Visual Studio 2019. One of my buttons links to a url using:
System.Diagnostics.Process.Start("www.google.com", "_blank");
However, when I debug my app locally, it works fine. Once I deploy the app and click on the same button, this error shows up:
Exception Details: System.ComponentModel.Win32Exception: No application is associated with the specified file for this operation
This points directly at the line where I make the call to System.Diagnostics.Process.Start.
What am I doing wrong?

How can I enroll certificate while no user logged in?

I use this link to Enrol new Certificate.
When the Windows is lock or logged in everything works fine and create request and install it properly.
Running the code as Windows Service, so when I restart the machine, and service is starting cannot create request and get the error the following line:
objPrivateKey.Create();
And the error is:
System.IO.FileNotFoundException: CertEnroll::CX509PrivateKey::Create: The system cannot find the file specified. 0x80070002 (WIN32: 2 ERROR_FILE_NOT_FOUND)
at CERTENROLLLib.IX509PrivateKey2.Create()
Any idea how can I fix this issue? Thanks

Retrieving the COM class factory for component with CLSID failed due to the following error: 80070005 Access is denied

I have an asp.net hosted in IIS. that uses the Com library "Microsoft Word 14.0 Object Library". I am using this to convert the word Document to HTML, on my machine it works. I have Office 2007 on my machine. but when i try to run my app on the server it gives me the Following error
Retrieving the COM class factory for component with CLSID
{000209FF-0000-0000-C000-000000000046} failed due to the following
error: 80070005 Access is denied. (Exception from HRESULT: 0x80070005
E_ACCESSDENIED)).
i have given all the permissions to the aspnet user and other users full access but this does not work,
From the Start menu, click Run and type Dcomcnfg.exe.
In Component Services, click Console root, expand Component Services, expand Computers, expand My computer,expand DCOMConfig.
Search for Microsoft Word 14.0 Object Library. Click on it.
Right click and select Properties.
On security tab, select Customize in "Launch and Activation" section.
Click edit and add identity of app pool under which you application is running.
Repeat above step for "Access Permission"

Error while access local machine outlook emails from web application

I have made a C#.net application to access all my folders and emails from my local machine outlook.
To make this application I have used COM object, my application is working fine with my local machine using link localhost:51514/mymail/list
Sample code
Microsoft.Office.Interop.Outlook.Application app = null;
app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("MAPI");
ns.Logon("abc#mydomain.com","password", true, true);
Globals.ThisAddIn.Application.CreateItem(Outlook.OlItemType.olMailItem);
MapModel.InboxFolder = app.ActiveExplorer().Session.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
MapModel.CategoryList = SetCategoryList(MapModel.InboxFolder);
but when I put this application on server and then try to access my email I get error at runtime.
ERROR: Retrieving the COM class factory for component with CLSID
{0006F03A-0000-0000-C000-000000000046} failed due to the following
error: 80080005 Server execution failed (Exception from HRESULT:
0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
The requirement of my project : where ever I open my application, it should access all emails from Microsoft outlook on that machine and list emails in my application.
seeking for some help, Thanks in advance.

Outlook Com Exception

I have a c# .net app that opens an instance of outlook and populates the bcc section of the email. When I run .Net locally, it works fine. If I go to the server and open IIS and browse to the app, it works fine.
When I browse to the app in Internet Explorer, it won't open outlook and populate the bcc.
Here is my code to open the instance of outlook.
Outlook.Application outlookApplication = new Outlook.Application();
Outlook.MailItem mailItem = (Outlook.MailItem)outlookApplication.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.BCC = emailList;
mailItem.Display(true);
Here is the warning from the event viewer in the server manager:
Exception information:
Exception type: COMException
Exception message: Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
What am I missing or what do I need to do to get this to work?
Your code is running on the server, not the client. You need to use a client-side script for that - assuming your script has the right to actually create local COM objects and the user is using IE (no other browsers support COM obejcts).
Secondly, Outlook, just like any other Office app, cannot be used in a service (such as IIS).

Categories

Resources