Spire.Email 4.11.1

Install-Package Spire.Email -Version 4.11.1
dotnet add package Spire.Email --version 4.11.1
<PackageReference Include="Spire.Email" Version="4.11.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Spire.Email --version 4.11.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Spire.Email, 4.11.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Spire.Email as a Cake Addin
#addin nuget:?package=Spire.Email&version=4.11.1

// Install Spire.Email as a Cake Tool
#tool nuget:?package=Spire.Email&version=4.11.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

.NET Library for Processing & Manipulating Email Files


Product PageDocumentationExamplesForumTemporary LicenseCustomized Demo

Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET, .Net Core, .Net Standard, .NET 5.0, MonoAndroid, Xamarin iOS) platform with fast and high quality performance.As an independent .NET Email API, Spire.Email for .NET doesn't need Microsoft outlook to be installed on the machine. However, it can incorporate Microsoft Outlook document creation capabilities into any developers' .NET applications.Spire.Email for .NET enables developers to create, edit and send out the message contents with attachments. Spire.Email for .NET supports to work with a number of Outlook email message formats, such as MSG, EML, EMLX, MHTML, PST, OST and TNEF files.Developers can use Spire.Email to receive message and get the detail information of the message, such as get mailbox information, get the message count, size, list, sequence number and the unique ID.

Main Features

  • Create email with HTML/Text mail body
  • Add, Extract, and Delete attachment
  • Load and Save messages from and to file or stream (EML, EMLX, MSG or MHTML formats)
  • Email file format conversion (EML, MSG or MHTML formats)
  • Send and receive emails using SMTP, POP3 and IMAP protocols
  • Get mailbox and messages info, retrieve and delete messages from server using POP3 protocols
  • Create, Delete, Select and Rename folders using IMAP protocols
  • Manipulate outlook storage files i.e. PST and OST

Supported Formats

  • Microsoft Outlook: MSG, PST, OST
  • Email: EML, EMLX, TNEF, MHTML

Receive and Save Email in C#

Use POP3 client
using Spire.Email;
using Spire.Email.Pop3;
using System;
using System.Globalization;

namespace ReceiveAndSaveEmailByUsingPOP3client
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create a POP3 client
            Pop3Client pop = new Pop3Client();
            //Set host, username, password etc. for the client
            pop.Host = "outlook.office365.com";
            pop.Username = "LeonDavisLD@outlook.com";
            pop.Password = "password";
            pop.Port = 995;
            pop.EnableSsl = true;
            //Connect the server
            pop.Connect();

            //Get the first message by its sequence number
            MailMessage message = pop.GetMessage(1);

            //Parse the message
            Console.WriteLine("------------------ HEADERS ---------------");
            Console.WriteLine("From   : " + message.From.ToString());
            Console.WriteLine("To     : " + message.To.ToString());
            Console.WriteLine("Date   : " + message.Date.ToString(CultureInfo.InvariantCulture));
            Console.WriteLine("Subject: " + message.Subject);
            Console.WriteLine("------------------- BODY -----------------");
            Console.WriteLine(message.BodyText);
            Console.WriteLine("------------------- END ------------------");

            //Save the message to disk using its subject as file name
            message.Save(message.Subject + ".eml", MailMessageFormat.Eml);

            Console.WriteLine("Message Saved.");
            Console.ReadKey();
        }
    }
}
Use IMAP client
using Spire.Email;
using Spire.Email.IMap;
using System;
using System.Globalization;


namespace ReceiveAndSaveEmailByUsingIMAPclient
{
    class Program
    {
        static void Main(string[] args)
        {
            //Create an IMAP client
            ImapClient imap = new ImapClient();
            // Set host, username, password etc. for the client
            imap.Host = "outlook.office365.com";
            imap.Port = 143;
            imap.Username = "LeonDavisLD@outlook.com";
            imap.Password = "password";
            imap.ConnectionProtocols = ConnectionProtocols.Ssl;
            //Connect the server
            imap.Connect();

            //Select Inbox folder
            imap.Select("Inbox");

            //Get the first message by its sequence number
            MailMessage message = imap.GetFullMessage(1);

            //Parse the message
            Console.WriteLine("------------------ HEADERS ---------------");
            Console.WriteLine("From   : " + message.From.ToString());
            Console.WriteLine("To     : " + message.To.ToString());
            Console.WriteLine("Date   : " + message.Date.ToString(CultureInfo.InvariantCulture));
            Console.WriteLine("Subject: " + message.Subject);
            Console.WriteLine("------------------- BODY -----------------");
            Console.WriteLine(message.BodyText);
            Console.WriteLine("------------------- END ------------------");

            //Save the message to disk using its subject as file name
            message.Save(message.Subject + ".eml", MailMessageFormat.Eml);

            Console.WriteLine("Message Saved.");
            Console.ReadKey();
        }
    }
}

Convert EML/EMLX to MHTML or MSG in C#

Convert EML/EMLX to MHTML
using Spire.Email;
using System;

namespace ConvertEMLandEMLXtoMHTML 
{
    class Program
    {
        static void Main(string[] args)
        {
            MailMessage message = MailMessage.Load("example.eml");
            message.Save("ToMhtml.mhtml", MailMessageFormat.Mhtml);
            Console.WriteLine("Done");
        }
    }
}
Convert EML/EMLX to MSG
using Spire.Email;
using System;

namespace ConvertEMLandEMLXtoMSG 
{
    class Program
    {
        static void Main(string[] args)
        {
            MailMessage message = MailMessage.Load("example.eml");
            message.Save("ToMsg.msg", MailMessageFormat.Msg);
            Console.WriteLine("Done");
        }
    }
}

Product PageDocumentationExamplesForumTemporary LicenseCustomized Demo

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
4.11.1 110 11/22/2021
4.7.0 989 7/29/2021
4.6.0 641 6/9/2021
4.5.0 473 5/18/2021
4.1.0 962 1/18/2021
3.6.7 5,295 6/9/2020
3.2.0 4,461 2/13/2020
3.1.0 523 1/3/2020
2.4.0 4,155 4/23/2019
2.1.0 1,041 1/14/2019
1.1.1 1,973 6/23/2017