Microsoft.Office.Interop.Outlook.Application oApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null; oApp = new Microsoft.Office.Interop.Outlook.Application();
Microsoft.Office.Interop.Outlook.NameSpace oNS = oApp.GetNamespace("MAPI");
var lst = new List<Msg>();
oNS.Logon("support@**.com", "*****", false, true);
inboxFolder = oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
for (int counter = 1; counter <= inboxFolder.Items.Count; counter++)
{
dynamic item = inboxFolder.Items[counter];
item = (Microsoft.Office.Interop.Outlook.MailItem)inboxFolder.Items[counter];
var msg = new Msg();
msg.subject = item.Subject;
msg.senderName = item.SenderName;
msg.body = item.Body;
if (item.UnRead == true)
{
lst.Add(msg);
}
}
return View(lst.ToList());