Open Source .NET MIME Creation & Parsing Library 

.NET MIME Creation and Parser Library for message Encryption, Decryption, and Signing as well as verifying Digital Signatures using S/MIME or OpenPGP Standards. 


MimeKit is an Open Source C# .NET library that enables software developers to create and parse email messages using the Multipurpose Internet Mail Extension (MIME). The main reason behind the development of the project was that it has been felt that the majority of email client (and server) software had less-than-satisfactory MIME implementations. Most of the times these email clients would incorrectly try to parse a MIME message and thus will not be able to get the full benefits that MIME.

The main aim of the MimeKit project is to address all these issues by as closely as possible and at the same time also provide computer programmers a tremendously easy to use high-level API. The great thing about the library is that it is much faster with all the available solutions. Even some commercial MIME parsers are not even come close to matching MimeKit's performance.

Getting Started with MimeKit

The easiest way to install MimeKit is through NuGet.  In Visual Studio's Package Manager Console, enter the following command

You can install it using pip.

install via NuGet

 Install-Package MimeKit  

You can also install MailKit from the GitHub repository. To do this using the command-line version of Git, you'll need to issue the following command in your terminal.

Install via GitHub 

git clone --recursive 

.NET API to Create New Messages

The Open Source API MailKit library enables software developers to create MIME messages with few simple commands.  A TextPart is a leaf-node MIME part with a text media-type. The first argument to the TextPart constructor specifies the media-subtype, in this case, plain. Another media subtype you are probably familiar with is the HTML subtype. The easiest way for both get and set the string content of the MIME part is the Text property.

Generate Message with Attachments using .NET API

MailKit API provides features for generating a message with attachments inside .NET applications.  Attachments are just like any other MimePart, the main difference is that they contain a content-disposition header holding value of the attachment instead of inline or no Content-Disposition header at all. To send out both a text/HTML and a text/plain version of the message, you need to create a TextPart for each part and then add them to a multipart/alternative.

Encrypt or Decrypt Messages with S/MIME

The Open Source MailKit API provides features for encrypting messages using S/MIME cryptography context. S/MIME uses an application/pkcs7-mime MIME part to encapsulate encrypted content.  Create the message body with the message text and some image attachments.  After that, you can encrypt the message body using the custom S/MIME cryptography context.