Load personal storage PST or OST with options
Leave feedback
On this page
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:
Option | Description |
---|---|
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. |
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);
}
}
WarningThis functionality is introduced in v20.6
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
NoteFrom v22.12 and greater
using (Converter converter = new Converter("sample.pst", (FileType fileType) =>
{
if (fileType == EmailFileType.Ost)
{
return new PersonalStorageLoadOptions
{
Folder = "Inbox",
};
}
if (fileType == EmailFileType.Msg)
{
return new EmailLoadOptions
{
ConvertOwner = true,
ConvertOwned = true,
Depth = 2
};
}
return null;
}))
{
int index = 0;
converter.Convert((FileType fileType) =>
{
string fileName = $"converted_{++index}.{fileType.Extension}";
return new FileStream(fileName, FileMode.Create);
}, (string sourceFileName, FileType fileType) =>
{
if (fileType == ImageFileType.Jpg)
{
return new ImageConvertOptions
{
Format = ImageFileType.Png
};
}
if (fileType == WordProcessingFileType.Docx)
{
return new PdfConvertOptions();
}
return new WebConvertOptions();
});
}
NoteBefore v22.12
using (Converter converter = new Converter("sample.pst", (FileType fileType) =>
{
if (fileType == PersonalStorageFileType.Ost)
{
return new PersonalStorageLoadOptions
{
Folder = "Inbox",
};
}
if (fileType == EmailFileType.Msg)
{
return new EmailLoadOptions
{
ConvertOwner = true,
ConvertOwned = true,
Depth = 2
};
}
return null;
}))
{
int index = 0;
converter.Convert((FileType fileType) =>
{
string fileName = $"converted_{++index}.{fileType.Extension}";
return new FileStream(fileName, FileMode.Create);
}, (string sourceFileName, FileType fileType) =>
{
if (fileType == ImageFileType.Jpg)
{
return new ImageConvertOptions
{
Format = ImageFileType.Png
};
}
if (fileType == WordProcessingFileType.Docx)
{
return new PdfConvertOptions();
}
return new MarkupConvertOptions();
});
}
WarningThis functionality is introduced in v20.6
Was this page helpful?
Any additional feedback you'd like to share with us?
Please tell us how we can improve this page.
Thank you for your feedback!
We value your opinion. Your feedback will help us improve our documentation.