Forem

GroupDocs
GroupDocs

Posted on

2 1

Retrieve Folders Contained in Outlook Data Files using C# .NET API

Application developers can get the list of folders and sub-folders from OST and PST Outlook data files as well as render the messages from these folders to PDF, HTML and Image formats with the help of the latest release of the .NET document rendering API. Also, you can programmatically omit empty columns while rendering Microsoft Excel worksheets within your .NET apps to reduce processing time and optimize memory usage when working with large files using GroupDocs.Viewer for .NET – http://bit.ly/2UNFCDL

Refer to following code examples/snippets for more help on how to perform these tasks inside your applications.

Below code snippet shows how you can retrieve the list of folders:

// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.GetConfigurations();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
string guid = DocumentName;
// Get Outlook document info
OutlookDocumentInfoContainer documentInfoContainer = imageHandler.GetDocumentInfo(guid) as OutlookDocumentInfoContainer;
foreach (string folderName in documentInfoContainer.Folders)
Console.WriteLine("Folder name: {0}", folderName);

Here's how you can retrieve sub-folders list:

// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.GetConfigurations();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
string guid = DocumentName;
// Create option object with specified folder name
DocumentInfoOptions options = new DocumentInfoOptions();
options.OutlookOptions.FolderName = "Inbox";
// Get outlook document info
OutlookDocumentInfoContainer documentInfoContainer = imageHandler.GetDocumentInfo(guid, options) as OutlookDocumentInfoContainer;
foreach (string folderName in documentInfoContainer.Folders)
Console.WriteLine("Folder name: {0}", folderName);

Below code snippet demonstrates how an email message from any of the retrieved folders can be rendered as an image:

// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.GetConfigurations();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
string guid = DocumentName;
// Create image options with specified folder name (use HtmlOptions to render into HTML)
ImageOptions options = new ImageOptions();
options.OutlookOptions.FolderName = "Inbox\\Sub Folder 1";
// Render document into image (List<PageHtml> is returned when rendering into HTML)
List<PageImage> pages = imageHandler.GetPages(guid, options);
foreach (PageImage page in pages)
{
// Save each image at disk
Utilities.SaveAsImage(page.PageNumber + "_" + DocumentName, page.Stream);
}

To render a message as PDF, refer to following code example:

// Setup GroupDocs.Viewer config
ViewerConfig config = Utilities.GetConfigurations();
// Create image handler
ViewerImageHandler imageHandler = new ViewerImageHandler(config);
string guid = DocumentName;
// Create pdf options with specified folder name
PdfFileOptions options = new PdfFileOptions();
options.OutlookOptions.FolderName = "Inbox";
// Get pdf document
FileContainer fileContainer = imageHandler.GetPdfFile(guid, options);
//Save file
Utilities.SaveFile(guid, fileContainer.Stream);

YouTube video tutorials of the GroupDocs API – http://bit.ly/2UKFx3L

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read more

Top comments (0)

Heroku

Simplify your DevOps and maximize your time.

Since 2007, Heroku has been the go-to platform for developers as it monitors uptime, performance, and infrastructure concerns, allowing you to focus on writing code.

Learn More

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay