I can get default folders from outlook no problem, but I'm struggling to get custom folders. I want to get the emails from a folder in my outlook called "Mass Archive" but I am struggling to understand how to use:
.GetFolderFromID()
From what I gathered, the first parameter it takes is the name of the folder e.g. .GetFolderFromID("Mass Archive")
But I cannot figure out what I am supposed to put as the object for the second parameter.
I'm really newbie so please explain things to me like I'm dumb.
outlookApplication = new Application();
outlookNameSpace = outlookApplication.GetNamespace("MAPI");
//inboxFolder = outlookNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderDeletedItems);
inboxFolder = outlookNameSpace.GetFolderFromID("Mass Archive", "Mass Archive");
mailItems = inboxFolder.Items;
foreach (MailItem item in mailItems)
{
emailDetails = new OutlookEmails
{
EmailFrom = item.SenderEmailAddress,
EmailSubject = item.Subject,
EmailBody = item.Body,
ReceivedTime = item.ReceivedTime
};
listEmailDetails.Add(emailDetails);
ReleaseComObject(item);
}