Open Source .NET Library for IMAP, POP3 & SMTP

Free C# .NET Library for Generating Message with Attachments, Encrypt/Decrypt Messages with PGP/MIME. 

 

MailKit is an Open Source .NET library for IMAP, POP3, and SMTP. It is a cross-platform mail client library built on top of MimeKit. The project aims to provide a robust, fully-featured and RFC-compliant SMTP, POP3, and IMAP client implementations

The API supports several important features related to SASL Authentication, proxy support, SMTP client, POP3 client, IMAP4 client, client-side sorting and threading of messages.

Getting Started with MailKit

The easiest way to install MailKit is via NuGet. To use it from Visual Studio’s Package Manager Console, please enter the following command.

install Mailkit via NuGet

Install-Package MailKit   

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 Mailkit via GitHub 

git clone --recursive https://github.com/jstedfast/MailKit.git 

Create New Messages via .NET

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/Decrypt Messages with PGP/MIME

The MailKit library provides features for encrypting email messages with PGP/MIME inside .NET applications. The PGP/MIME uses a MIME part with a multipart/encrypted mime-type to encapsulate encrypted data. If you want to encrypt a message it is always a better approach to use SecureMailboxAddress instead of a MailboxAddress for every recipient, which will allow users to specify the unique fingerprint of each recipient's PGP key.