I am trying to use Microsoft.Office.Interop.Outlook to receive emails from my Outlook mailbox. This is my code:
Application app = new Application();
NameSpace ns = app.Session;
MAPIFolder inbox = ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
Items items = inbox.Items;
foreach (Microsoft.Office.Interop.Outlook.MailItem mail in items)
{
if (mail as MailItem != null)
{
Console.WriteLine(mail.Subject.ToString());
Console.WriteLine(mail.Body.ToString());
Console.ReadKey();
}
}
When I do this, it works - sort of. It shows only one email. There should be three of them. The email he shows is the oldest of them ... why don't I get all three? Is there a mailing address other than MailItem that will be in my inbox?
source
share