I've got some code for composing an e-mail from the contents of an RTF box. The first time I execute it, everything works fine. If I close my app and then re-run it, however, I always receive the following error:
Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80040154.
When reaching the line:
Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
The only way I can solve this is to go into Add/Remove Programs and uninstall/reinstall the interop assemblies for Outlook. I have no idea what's causing this, because Microsoft's programmers apparently didn't see fit to include actual error descriptions that help you fix them.
Can anyone help me with this issue?
Code:
Outlook.Application outlookApp = new Microsoft.Office.Interop.Outlook.Application();
Outlook.MailItem email = (Outlook.MailItem)outlookApp.CreateItem(Microsoft. Office.Interop.Outlook.OlItemType.olMailItem);
email.Body = rtfReader.Rtf;
email.BodyFormat = Microsoft.Office.Interop.Outlook.OlBodyFormat.olFo rmatRichText;
email.Display(false);