I am using the following code as I attempt to connect to my Outlook mail. Now, I must be doing something wrong because I try to get the inbox mails and I always get 0 mails
I could solve this! It was quite easy actually. Here is how I could access the desired folder:
// my-account@myserver.com is the name of my account
// Unsent mails is the name of the folder I wanted to access
inboxFolder = nameSpace.Folders["my-account@myserver.com"].Folders["Unsent mails"];
foreach (Microsoft.Office.Interop.Outlook.MailItem mailItem in inboxFolder.Items)
{
if (mailItem.UnRead) // I only process the mail if unread
{
Console.WriteLine("Accounts: {0}", mailItem.Body);
}
}