I tried to open outlook window with body to send a message. When I works with my local it's opening perfectly. But when I work with IIS the outlook window is not opening.
public static void SendMailInOutlook(Page CurrentPage, Type ScriptType,
string Subject, string Recipients, Dictionary<string, string> emailInputs,
string emailTemplatePath)
{
static Microsoft.Office.Interop.Outlook.Application outlookApp;
static Microsoft.Office.Interop.Outlook._MailItem mailItem;
outlookApp = new Microsoft.Office.Interop.Outlook.Application();
mailItem = (Microsoft.Office.Interop.Outlook._MailItem)outlookApp.CreateItem(
Microsoft.Office.Interop.Outlook.OlItemType.olMailItem);
mailItem.Subject = Subject;
mailItem.To = Recipients;
mailItem.HTMLBody = SendMail.GetEmailContent(emailInputs, emailTemplatePath);
Thread newThread = new Thread(SendEmailToOutLook);
newThread.Start();
}
static void SendEmailToOutLook()
{
string sMsg = "Email sent successfully.";
try
{
mailItem.Display(true);
}
catch (Exception ex)
{
sMsg = ex.Message;
}
}