Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why am I receiving exception from Office's Outlook library?

I have an application that calls

Email hello = new Email(appropriate constructor); hello.Email_Send(); 

I'm receiving the exception:

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)).

from System.Runtime.InteropServices.COMException.

using O = Microsoft.Office.Interop.Outlook;     class Email {     public void Email_Send()     {         O.Application outlook = new O.Application(); //Exception thrown here.         O.MailItem message = outlook.CreateItem(O.OlItemType.olMailItem);         message.To = Receiver;         message.CC = Sender;         message.Subject = Subject;         message.Body = "This is an automated message sent at " + DateTime.Now.ToString("HH:mm:ss") + " about " + Body_Topic + System.Environment.NewLine + Body_Content ;         message.Send();     } } 

This error has never happened previously, and there has been no change to the code that I know of. http://support.microsoft.com/kb/825118 doesn't seem to fit the my symptoms - My computer doesn't stop responding, etc. Any help diagnosing the issue would be greatly appreciated!

like image 686
Zee Avatar asked Oct 12 '12 14:10

Zee


People also ask

Is Microsoft having problems with Outlook?

Everything is up and running.

How do you fix the Cannot start Microsoft Outlook Cannot open the Outlook window the set of folders Cannot be opened?

Find the Outlook.exe file on your computer. Right-click the Outlook.exe file, choose Properties, and then choose the Compatibility tab. If any of the boxes on the Compatibility tab are checked, uncheck them, then choose Apply > OK. Restart Outlook.

Why can't my Outlook connect to the server?

If you still experience an Outlook error message cannot connect to a server problem, then it's time to check your internet connection. If there is a problem with a network or it isn't working, then you won't be able to connect to any server.


2 Answers

This error was caused by visual studio being run as admin. Outlook doesn't allow separate users to access the same mailbox (I had the outlook application open on desktop). Even though I have local admin access w/ my domain user, running VS as admin must associate the process to a different user object? Not exactly sure how this works, but... Resolved.

like image 154
Zee Avatar answered Oct 05 '22 02:10

Zee


I ran into the same issue, and as previously said: if Visual Studio is running as Administrator then Outlook prevents another instance with a different user. My VS solution is starting several projects, and I need it to run as Administrator, so what I did is run Outlook as administrator while debugging. This solved my problem.

like image 30
lukiller Avatar answered Oct 05 '22 03:10

lukiller