NuGet Status Maven Central

Download source code: ZIP file

A portable library in C# and Java for parsing and generating Internet mail messages.

Note that sending and receiving email messages is outside the scope of this library; however, an application that sends and/or receives such messages can use this library to help interpret those messages.


See the Java API documentation.

See the C# (.NET) API documentation.

How to Install

Starting with version 0.6.1, the C# implementation is available in the NuGet Package Gallery under the name PeterO.MailLib. To install this library as a NuGet package, enter Install-Package PeterO.MailLib in the NuGet Package Manager Console.

Starting with version 0.6.1, the Java implementation is available as an artifact in the Central Repository. To add this library to a Maven project, add the following to the dependencies section in your pom.xml file:


In other Java-based environments, the library can be referred to by its group ID (com.upokecenter), artifact ID (maillib), and version, as given above.

Source Code

Source code is available in the project page.


An example of reading an email message from a file:

// Create a file stream from the email message file
using(var file = new System.IO.FileStream("email.eml",System.IO.FileMode.Read)){
  // Read the email message
  var message = new Message(file);
  // Output each address in the From header
  foreach(var addr in message.FromAddresses){
     Console.WriteLine("From: "+addr);
  // Output each address in the To header
  foreach(var addr in message.ToAddresses){
     Console.WriteLine("To: "+addr);
  // Output the message's text

Release Notes

Version 0.15.0:

Version 0.14.0:

Version 0.13.1:

Version 0.13.0:

Version 0.12.0:

Version 0.11.0:

See for release notes for older versions.


Written in 2013-2018 by Peter O.

Any copyright to this work is released to the Public Domain. In case this is not possible, this work is also licensed under Creative Commons Zero (CC0): (For exceptions, see