The below code opens a mail with a file attached on clicking a button say “Open mail� But when you click “Open mail�continuously, it gives this error (like in the fourth or fifth time/click)
<Message> Creating an instance of the COM component with CLSID {0006F03A-0000-0000-C000-000000000046} from the IClassFactory failed due to the following error: 80010108.</Message>
//Get Outlook object.
Microsoft.Office.Interop.Outlook.Application outlookObj = new Microsoft.Office.Interop.Outlook.Application();
if (outlookObj == null)
{
System.Diagnostics.Process.Start("Outlook.exe");
outlookObj = new Microsoft.Office.Interop.Outlook.Application();
}
Microsoft.Office.Interop.Outlook.MailItem outlookMailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlookObj.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
if (outlookMailItem == null)
{
System.Diagnostics.Process.Start("Outlook.exe");
outlookMailItem = (Microsoft.Office.Interop.Outlook.MailItem)outlookObj.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
}
outlookMailItem.To = "xyz@abc.com";
outlookMailItem.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFormatHTML;
outlookMailItem.Attachments.Add(filePath, (int)Microsoft.Office.Interop.Outlook.OlAttachmentType.olByValue, 1, null);
outlookMailItem.Display(true);
How to get rid of it ?