Skip to content

Instantly share code, notes, and snippets.

@tim-bellette
Last active December 6, 2017 22:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tim-bellette/4fdacd2c41e7c94616e88b0a24a90b51 to your computer and use it in GitHub Desktop.
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.
<?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>
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