Load personal storage PST or OST with options

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Conversion MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-conversion -- dnx GroupDocs.Conversion.Mcp --yes
Folders, licensing and more →

GroupDocs.Conversion provides PersonalStorageLoadOptions to give you control over how the source personal storage (PST/OST) document will be processed. The following options could be set:

OptionDescription
ConvertOwned Controls whether owned documents of the document container must be converted.
ConvertOwner Controls whether the document container itself must be converted. If this property is true the document container will be the first converted document.
Depth Controls how many levels in depth to perform the conversion.
Folder  A folder to be processed. Default is Inbox.

Get folders from personal storage

The following code snippet shows how to get folders within the personal storage document:

using (Converter converter = new Converter("sample.pst"))
{
    var documentInfo = converter.GetDocumentInfo();
    var ostInfo = (PersonalStorageDocumentInfo) documentInfo;
    Console.WriteLine(ostInfo.RootFolderName);
    foreach (var folder in ostInfo.Folders)
    {
        Console.WriteLine(folder);
    }
}

Convert each personal storage content to different formats

The following code snippet shows how to convert each personal storage content to a different format based on the content type:

  • JPG attachments will be converted to PNG
  • DOCX attachments will be converted to PDF
  • Emails and all other types will be converted to HTML
using (Converter converter = new Converter("sample.pst", (LoadContext loadContext) =>
       {
           if (loadContext.SourceFormat == EmailFileType.Ost)
           {
               return new PersonalStorageLoadOptions
               {
                   Folder = "Inbox",
               };
           }
           if (loadContext.SourceFormat == EmailFileType.Msg)
           {
               return new EmailLoadOptions
               {
                   ConvertOwner = true,
                   ConvertOwned = true,
                   Depth = 2
               };
           }
           return null;
       }))
{
    int index = 0;
    converter.Convert((SaveContext saveContext) =>
    {
        string fileName = $"converted_{++index}.{saveContext.TargetFormat.Extension}";
        return new FileStream(fileName, FileMode.Create);
    }, (ConvertContext convertContext) =>
    {
        if (convertContext.SourceFormat == ImageFileType.Jpg)
        {
            return new ImageConvertOptions
            {
                Format = ImageFileType.Png
            };
        }
        if (convertContext.SourceFormat == WordProcessingFileType.Docx)
        {
            return new PdfConvertOptions();
        }
        return new WebConvertOptions();
    });
}