Interop-Outlook error on Teamcity

0

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?

c#
selenium
teamcity
office-interop
windows-server-2008-r2
asked on Stack Overflow Apr 2, 2017 by Yaniv Eliav • edited Apr 2, 2017 by Yaniv Eliav

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0