I have some code that lauches an email (Microsoft Outlook) and add the emailadress, subject, attachment and body
As soon as I the code hits Outlook.Application outlookApp = new Outlook.Application();
it throws an exception only if Microsoft outlook was already open.
If outlook wasn't open on the user machine all works welol.
Any idean how I can resolve this?I know I can ask the user to close the app, but that is ionconvenient
Outlook.Application outlookApp = new Outlook.Application();
Outlook.MailItem message = (Outlook.MailItem)outlookApp.CreateItem(Outlook.OlItemType.olMailItem);
message.Subject = “subject “
message.Body = “”;
int attachmentLocation = 1;
message.Attachments.Add(“” + ConfigurationSettings.AppSettings["Atachments"] + “Course Schedules for “ + lblProviderName.Text + “.xls”, Outlook.OlAttachmentType.olByValue,
attachmentLocation, “Course Schedules for “ + lblProviderName.Text + “.xls”);