I've been trying to use this interop in my MVC 4 project. I tried to make it simple just to get the idea. but I get an error "Retrieving the COM class factory for component with CLSID {0006F03A-0000-0000-C000-000000000046} failed due to the following error: 80010001 Call was rejected by callee. (Exception from HRESULT: 0x80010001 (RPC_E_CALL_REJECTED))."
Here's my simple code:
using Outlook = Microsoft.Office.Interop.Outlook;
[HttpPost]
public ActionResult SendEmail(SendEmailModel model)
{
if (ModelState.IsValid)
{
Outlook.Application app = new Outlook.Application();
Outlook.NameSpace ns = app.GetNamespace("MAPI");
ns.Logon("", "", Missing.Value, Missing.Value);
Outlook.MailItem mailItem = (Outlook.MailItem)app.CreateItem(Outlook.OlItemType.olMailItem);
mailItem.To = model.To;
mailItem.Subject = model.Subject;
mailItem.Body = model.Message;
((Outlook.MailItem)mailItem).Send();
app = null;
ns = null;
return RedirectToAction("Index", "TechFile");
}
return View(model);
}
Anyway I found Outlook redemption is an alternative way of doing this. but I don't know to get it started.