Menu - Top - Home - Donate to Me

MailLib

NuGet Status Maven Central

Download source code: ZIP file

If you like this software, consider donating to me at this link: http://peteroupc.github.io/


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

Documentation

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:

<dependency>
  <groupId>com.upokecenter</groupId>
  <artifactId>maillib</artifactId>
  <version>0.10.0</version>
</dependency>

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.

Example

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
  Console.WriteLine(message.BodyString);
}

Release Notes

Version 0.10.0:

Version 0.9.2:

Version 0.9.1:

Version 0.9:

See History.md for release notes for older versions.

About

Written in 2013-2014 by Peter O.

Any copyright is dedicated to the Public Domain. http://creativecommons.org/publicdomain/zero/1.0/ (For exceptions, see LICENSE.md.)

If you like this, you should donate to Peter O. at: http://peteroupc.github.io/