Skip to content

Instantly share code, notes, and snippets.

@codesteps
Created August 19, 2018 13:25
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Office.Tools.Ribbon;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace CodeSteps_AddIn
{
public partial class CodeSteps
{
private void CodeSteps_Load(object sender, RibbonUIEventArgs e)
{
}
private void button1_Click(object sender, RibbonControlEventArgs e)
{
Outlook.Explorer explorer = Globals.ThisAddIn.Application.ActiveExplorer();
// -- Display folders list
if (explorer != null)
{
String folders = "";
foreach (Outlook.Folder mailbox in explorer.Session.Folders)
{
folders += mailbox.Name + "\n";
try
{
foreach (Outlook.Folder folder in mailbox.Folders)
{
folders += "\t" + folder.Name + "\n";
}
}
catch(Exception ex)
{
; // nothing to do, for the moment
}
}
System.Windows.Forms.MessageBox.Show(folders);
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment