I am using the below code to get the mails from the inbox folder and it is working fine for me
Microsoft.Office.Interop.Outlook.Application app = null;
Microsoft.Office.Interop.Outlook._NameSpace ns = null;
//Microsoft.Office.Interop.Outlook.MailItem item = null;
Microsoft.Office.Interop.Outlook.MAPIFolder inboxFolder = null;
app = new Microsoft.Office.Interop.Outlook.Application();
ns = app.GetNamespace("MAPI");
//ns.Logon(null, null, false, false);
inboxFolder = ns.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox) ;
var list = new List<string>();
//System.IO.StreamWriter strm = new System.IO.StreamWriter("C:/Test/Inbox.txt");
for (int counter = inboxFolder.Items.Count; counter > 0; counter--)
{
dynamic item = inboxFolder.Items[counter];
string SB = item.Subject.ToUpper();
}
I want to get the data from a specific folder called "Career" which was created by me where all the mails are forwarded by a rule. I want to read all the mails from the folder "Career" as shown in the picture but not sure how to do it.
Any help would be greatly appreciated. Thank you.
If it is on the same level as your Inbox, use
yourOtherFodler = ((MAPIFolder)inboxFolder.Parent).Folders["Career"];