Last active
December 6, 2017 22:58
-
-
Save tim-bellette/4fdacd2c41e7c94616e88b0a24a90b51 to your computer and use it in GitHub Desktop.
Simple console application to output a hierarchy of Outlook folders, with their Entry ID, using NetOffice.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?xml version="1.0" encoding="utf-8"?> | |
<packages> | |
<package id="NetOffice.Core" version="1.7.3.0" targetFramework="net461" /> | |
<package id="NetOffice.Outlook" version="1.7.3.0" targetFramework="net461" /> | |
</packages> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace OutlookFolderIdGrabber | |
{ | |
public class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
using (var application = new NetOffice.OutlookApi.Application()) | |
{ | |
DisplayFolder(application.Session.DefaultStore.GetRootFolder()); | |
} | |
} | |
private static void DisplayFolder(NetOffice.OutlookApi.MAPIFolder folder, int level = 0) | |
{ | |
Console.WriteLine($"{new string(' ', level)}{folder.Name} : {folder.EntryID}"); | |
foreach (NetOffice.OutlookApi.MAPIFolder childFolder in folder.Folders) | |
{ | |
DisplayFolder(childFolder, level + 1); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment