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.
Related
I know this would be a duplicate question. I tried all the ways suggested in multiple websites, but my issue didn't get solved. I am getting the below error
System.UnauthorizedAccessException: 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)) at
Application appWord = new Application();
wordDocument = appWord.Documents.Open(strFilePath);
wordDocument.ExportAsFixedFormat(pdfPath, WdExportFormat.wdExportFormatPDF);
appWord.Quit();
Same solution working fine in Local, but in in server its giving the above error. I have added 'Network Service' user to 'Microsoft Word 97 - 2003 Document'and given all the permissions, Do these changes required server reboot?, and created desktop folders as well and I have MS word 2016 installed on web server. Thanks in advance.
I have several project which requires me to connect an email account and retrieve data from email arrives.
When running locally on my PC, everything works fine.
I have Teamcity (latest version) installed on a Windows 2008 server.
This is my code where it seems it fails:
public void DeleteAllEmails(string Folder)
{
Application myApp = new ApplicationClass();
NameSpace mapiNameSpace = myApp.GetNamespace("MAPI");
MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox).Folders[Folder];
List<MailItem> ReceivedEmails = new List<MailItem>();
foreach (MailItem mail in myInbox.Items)
{ ReceivedEmails.Add(mail); }
foreach (MailItem mail in ReceivedEmails)
{
mail.Delete();
}
}
When running my tests from TeamCity, I get this error:
[ReportAppeal.dll] ReportAppeal.MainTestRunner.Create2ApplicationsTryOneWithcorrectReportIdSecondwithUncorrectReportId("PostOffice") (2m:06s)
[13:56:35][ReportAppeal.MainTestRunner.Create2ApplicationsTryOneWithcorrectReportIdSecondwithUncorrectReportId("PostOffice")] System.Runtime.InteropServices.COMException : 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)).
Or
[ReportAppeal.MainTestRunner.CheckStatusFor2ApplicationsOfTheSameCarNumber("PostOffice")] at ReportAppeal.Email.DeleteAllEmails(String Folder) in C:\BuildAgent\work\430330697c233f87\Projects\ReportAppeal\ReportAppeal\Email.cs:line 50
at ReportAppeal.MainTestRunner.CheckStatusFor2ApplicationsOfTheSameCarNumber(String Address) in C:\BuildAgent\work\430330697c233f87\Projects\ReportAppeal\ReportAppeal\MainTestRunner.cs:line 427
[13:50:09][ReportAppeal.dll] ReportAppeal.MainTestRunner.Create2ApplicationsButFinishProcessJustAfterOne("Email") (2m:07s)
I have Outlook 2013 installed on my server so the environments are pretty similar.
What could I do in order to make it work?
I am trying to add site binding programmatically. Here is my code:
using (ServerManager manager = ServerManager.OpenRemote("serverName"))
{
manager.Sites["siteName"].Bindings.Add(string.Format("*:{1}:{0}.localhost", clientCode, port), "http");
manager.CommitChanges();
}
I am getting the following Error. How do I get around this?
UnAuthorizedException: Retrieving the COM class factory for remote component with CLSID {} from machine failed due to the following error: 80070005
The account runs the code must be the administrator of the remote machine and also the DCOM related ports on the remote machine must be opened at firewall.
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).
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.