Ragaei Mahmoud
Ragaei Mahmoud

Reputation: 457

Error : Retrieving the COM class factory for component with CLSID {xxxx} failed due to the following error: 80080005

I am using My Company's Outlook account to send mails, but i got this error : Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80080005.

The Sendmail method is given below:

  public static void SendEmail(string _ToEmail, string _Subject, string _EmailBody)
  {
    oApp = new Microsoft.Office.Interop.Outlook.Application();

    Microsoft.Office.Interop.Outlook.MailItem email = (Microsoft.Office.Interop.Outlook.MailItem)(oApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem));
    email.Recipients.Add(_ToEmail);
    email.Subject = _Subject;
    email.Body = _EmailBody;
    ((Microsoft.Office.Interop.Outlook.MailItem)email).Send();
  }

and also I added both Microsoft.Office.Interop.Outlook.dll and office.dll to my solution.

any suggestion?

Upvotes: 2

Views: 3508

Answers (1)

Eben Roux
Eben Roux

Reputation: 13256

COM requires STA threads. Ensure that you are instantiating the object on an STA thread.

Upvotes: 1

Related Questions