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?
Related
Problem statement
Trying to connect RavenDB Cloud service using AWS Lambda function, for one of my POC, but failed to connect.
Background
I am using the client certificate (.pfx) file for this. It throws error exactly during certificate assign with X509Certificate2. I have converted the certificate to byte[] and passed. The certificate I am using has full access to the database. I am included the error below
Code
if (_bClientCertificate != null)
{
if (_bClientCertificate.Length > 0)
{
xclientCertificate = new X509Certificate2(_bClientCertificate);
}
}
IDocumentStore store = new DocumentStore()
{
Certificate = xclientCertificate, //Error occured here
Urls = _Urls,
Database = _DBName
}.Initialize();
Exception Details :
System.IO.FileLoadException
HResult=0x80131509
Message=Could not load file or assembly 'Sparrow, Version=4.2.2.0, Culture=neutral, PublicKeyToken=37f41c7f99471593'. An operation is not legal in the current state. (Exception from HRESULT: 0x80131509)
Source=Raven.Client
StackTrace:
at Raven.Client.Documents.Subscriptions.DocumentSubscriptions..ctor(IDocumentStore store) in C:\Builds\RavenDB-Stable-4.2\42017\src\Raven.Client\Documents\Subscriptions\DocumentSubscriptions.cs:line 33
at Raven.Client.Documents.DocumentStoreBase..ctor() in C:\Builds\RavenDB-Stable-4.2\42017\src\Raven.Client\Documents\DocumentStoreBase.cs:line 28
at Firecloud.DataAccess.RavenDB.SessionStore.CreateStore() in C:\Works\SourceCode\FC\Library\RavenDB\FC.DataAccess.Raven\SessionStore.cs:line 87
at System.Lazy`1.ViaFactory(LazyThreadSafetyMode mode)
I've had this issue before, apparently some visual C++ libraries could be missing.
Try installing Visual C++ Redistributable for Visual Studio 2015.
I'm executing code(create bitvise ssh server -user) normally(without run as administrator visual studio) then give error like Retrieving the COM class factory for component with CLSID {730D6BA1-01B1-5074-7182-990EF773DB5F} failed due to the following error: 80080005 Server execution failed (Exception from HRESULT: 0x80080005 (CO_E_SERVER_EXEC_FAILURE)).
while open application using run as administrator visual studio then its working,please advise for how do i set this settings for run this code without run as administrator visual studio.,below is my code snippet.
using BssCfg726Lib;
try
{
var cfg = new CBssCfg726("BssCfg726.BssCfg726");
cfg.SetSite("Bitvise SSH Server");
cfg.LockServerSettings();
cfg.LoadServerSettings();
cfg.settings.access.winAccountsEx.#new.winDomain = "Domain_Name_from_SCI_DEPOLYE1";
cfg.settings.access.winAccountsEx.#new.winAccount = "Domain_Name_from_SCI_DEPOLYE1";
cfg.settings.access.winAccountsEx.#new.loginAllowed = cfg.DefaultYesNo.yes;
cfg.settings.access.winAccountsEx.#new.xfer.mountPointsEx.Clear();
cfg.settings.access.winAccountsEx.#new.xfer.mountPointsEx.#new.realRootPath = "C:\\Sftp\\User";
cfg.settings.access.winAccountsEx.#new.xfer.mountPointsEx.NewCommit();
cfg.settings.access.winAccountsEx.NewCommit();
cfg.UnlockServerSettings();
cfg.SaveServerSettings();
}
catch (Exception ex)
{
throw ex;
}
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 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.
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).