Code snippet :
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.OlItemType.olMailItem));
email.Recipients.Add(_ToEmail);
email.Subject = _Subject;
email.Body = _EmailBody;
((Microsoft.Office.Interop.Outlook.MailItem)email).Send();
}
this method works well when i tested it in another project(located in file system) but when tried to test it from IIS (virtual site);It throw this exception in line : email.Recipients.Add(_ToEmail);
any help will be appreciated
P.S. the ASPNET account has the administrator permission
thanks in advance.
Make sure that the reference is set in your web.config
User contributions licensed under CC BY-SA 3.0