I am trying to simply read and print the contents of emails from a specific folder and another inbox in Outlook using C# (not my default inbox). I'm finding it difficult to find examples of this on the web and have failed on my own. I know how to print the emails of the default account as well, just not additional ones.
My code here simply iterates over a list of all the inboxes and prints their names out. The one I want to read is the first element in the collection. I appreciate any help with this issue. Thanks.
using System;
using System.Collections;
using Microsoft.Office.Interop.Outlook;
public class StorageReplies {
public static void Main() {
Application app = new Microsoft.Office.Interop.Outlook.Application();
_NameSpace ns = app.GetNamespace("MAPI");
Folders folders = ns.Folders;
foreach(MAPIFolder f in folders) {
Console.WriteLine(f.Name);
}
}
}