XstReader.Api 1.0.3

There is a newer version of this package available.
See the version list below for details.
dotnet add package XstReader.Api --version 1.0.3                
NuGet\Install-Package XstReader.Api -Version 1.0.3                
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="XstReader.Api" Version="1.0.3" />                
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add XstReader.Api --version 1.0.3                
#r "nuget: XstReader.Api, 1.0.3"                
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
// Install XstReader.Api as a Cake Addin
#addin nuget:?package=XstReader.Api&version=1.0.3

// Install XstReader.Api as a Cake Tool
#tool nuget:?package=XstReader.Api&version=1.0.3                

You can buy me a beer 😉 (https://www.buymeacoffee.com/iluvadev)

XstReader.Api

XstReader.Api is an open source library for read Microsoft Outlook’s .ost and .pst files, written entirely in C#, over .NET Standard 2.1, and with no dependency on any Microsoft Office components. Is an open source, cross-platform library that can be used in any .NET project (.NET Standard, .NET Core, .NET Framework and .NET 5+)

This library is the core of XstReader and XstExporter, included in the github repository iluvadev/XstReader.

Usage

The use of this library is simple. There is a little summary:

  • The .ost or .pst file is represented with XstFile class
  • An XstFile has a RootFolder property of type XstFolder, with the Root folder of message structure in the file
  • Each XstFolder has:
    • Messages with all messages included in the Folder (type: XstMessage)
    • Folders with all Folders under that Folder (type: XstFolder)
  • Each XstMessage has:
    • Recipients with all the Recipients involved in the Message (type: XstRecipient)
    • Body with the body of the Message (type: XstMessageBody)
    • Attachments with all the Attachments of the Message (type: XstAttachment)
  • Each Folder (XstForlder), Message (XstMessage), Recipient (XstRecipient) and Attachment (XstAttachment) have its own Properties
  • You can call ClearContents() of an element to release internal data used by the object: it will find the released data again when needed.

Examples

Usage of XstReader.Api is simple. Here are some basic examples to show how easy it is to use the library. Obviously, this is just a simplification: objects have many more methods and properties than those shown.

Open .ost or .pst file
public void OpenOstOrPstFile(string fileName)
{
  // Note the "using": XstFile implements IDisposable
  // The file remains opened until dispose of XstFile
  using(var xstFile = new XstFile(fileName))
  {
    ProcessFolder(xstFile.RootFolder);
  }
}
Processing a Folder
public void ProcessFolder(XstFolder folder)
{
  // We can process the properties of the Folder
  var properties = folder.Properties; 

  // Messages in the folder
  foreach(var message in folder.Messages)
  {
    ProcessMessage(message);
  }

  // Folders inside the folder
  foreach(var childFolder in folder.Folders)
  {
    ProcessFolder(childFolder);
  }
}
Processing a Message
public void ProcessMessage(XstMessage message)
{
  // We can process the properties of the Message
  var properties = message.Properties;
  
  // Recipients of the Message
  ProcessRecipients(message.Recipients);
  
  // Body of the Message
  ProcessBody(message.Body);
  
  // Attachments in the message
  foreach (var attachment in message.Attachments)
  {
    ProcessAttachment(attachment);
  }
}
Processing Recipients
public void ProcessRecipients(XstRecipientSet recipients)
{
  // We have info about recipients involved in a Message:
  XstRecipient originator = recipients.Originator;
  XstRecipient originalSentRepresenting = recipients.OriginalSentRepresenting;
  XstRecipient sentRepresenting = recipients.SentRepresenting;
  XstRecipient sender = recipients.Sender;
  IEnumerable<XstRecipient> to = recipients.To;
  IEnumerable<XstRecipient> cc = recipients.Cc;
  IEnumerable<XstRecipient> bcc = recipients.Bcc;
  XstRecipient receivedBy = recipients.ReceivedBy;
  XstRecipient receivedRepresenting = recipients.ReceivedRepresenting;

  // All Recipients with its own properties:
  var senderProperties = sender.Properties;
}
Processing Body
public void ProcessBody(XstMessageBody body)
{
  switch (body.Format)
  {
    case XstMessageBodyFormat.Html:
	  Console.Write("body in html"); break;
    case XstMessageBodyFormat.Rtf:
      Console.Write("body in rtf"); break;
    case XstMessageBodyFormat.PlainText:
      Console.Write("body in txt"); break;
  }

  // The Body in the format can be accessed by text or bytearray
  var text = body.Text;
  var bytes = body.Bytes;
}
Processing Attachment
public void ProcessAttachment(XstAttachment attachment)
{
  string fileName = "myAttachment";

  // We can process the properties of the Attachment
  var properties = attachment.Properties;

  // We can open attached Messages
  if (attachment.IsEmail)
    ProcessMessage(attachment.AttachedEmailMessage);
  // We can save attachments
  else if (attachment.IsFile)
    attachment.SaveToFile(fileName, attachment.LastModificationTime);
}
Product Compatible and additional computed target framework versions.
.NET net5.0 was computed.  net5.0-windows was computed.  net6.0 was computed.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 was computed.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 was computed.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed. 
.NET Core netcoreapp2.0 was computed.  netcoreapp2.1 was computed.  netcoreapp2.2 was computed.  netcoreapp3.0 was computed.  netcoreapp3.1 was computed. 
.NET Standard netstandard2.0 is compatible.  netstandard2.1 was computed. 
.NET Framework net461 was computed.  net462 was computed.  net463 was computed.  net47 was computed.  net471 was computed.  net472 was computed.  net48 was computed.  net481 was computed. 
MonoAndroid monoandroid was computed. 
MonoMac monomac was computed. 
MonoTouch monotouch was computed. 
Tizen tizen40 was computed.  tizen60 was computed. 
Xamarin.iOS xamarinios was computed. 
Xamarin.Mac xamarinmac was computed. 
Xamarin.TVOS xamarintvos was computed. 
Xamarin.WatchOS xamarinwatchos was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.6 16,513 12/13/2022
1.0.4 427 8/15/2022
1.0.3 578 1/28/2022
1.0.2 437 1/27/2022
1.0.1 426 1/26/2022
1.0.0 433 1/25/2022
0.4.0 526 1/24/2022
0.3.0 559 1/24/2022
0.2.0 552 1/20/2022