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.O开发者_开发问答lItemType.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?
COM requires STA threads. Ensure that you are instantiating the object on an STA thread.
精彩评论