1. Products
  2.   Email
  3.   .NET
  4.   Aspose.Email for .NET

Aspose.Email for .NET

 
 

C# .NET API to Process Microsoft Outlook Email

A Powerful Email Processing API that allows to create, manipulate, analyze, convert and transmit Email messages without using Microsoft Outlook.

Aspose.Email for .NET is a dominant and versatile email management API that gives software developers the ability to manipulate, read, create and convert email messages in a variety of formats, including Microsoft Exchange Server, Microsoft Outlook, and IMAP. The library helps developers to create a wide variety of email processing applications with little effort and cost. The library fully supports asynchronous and synchronous programming models.

Aspose.Email for .NET has included various useful features for loading and saving email messages in a variety of file formats MSG, PST, OST, OFT, EML, EMLX, MBOX, ICS, VCF, HTML, MHTML and more. This means that you can easily convert between different email file formats and ensure that your messages are compatible with a wide range of email clients. The library has included various security features including support for cram-MD5 authentication, digest-MD5 authentication, AUTH LOGIN authentication, and so on. The library supports a number of network protocols, such as SMTP, MIME, POP3 and IMAP.

Aspose.Email for .NET library offers a number of great features that makes it a valuable tool for any developer working with email messages, such as creating emails containing plain text or HTML, adding or removing attachments to emails, embedding objects to emails, creating emails from HTML contents, importing and exporting emails, sending emails in batches, saving bulk email messages, template-based mail merging, creating email template from file, adding iCalender events to email messages, customizing email headers, setting message priority, date or time, and so on.

Previous Next

Getting Started with Aspose.Email for .NET

The recommend way to install Aspose.Email for .NET is using NuGet. Please use the following command for a smooth installation.

Install Aspose.Email for .NET via NuGet

NuGet\Install-Package Aspose.Email -Version 22.12.0 
You can also download it directly from Aspose product page.

Create & Send Email Messages via .NET API

Aspose.Email for .NET has included support for creating and manipulating email message inside C# .NET applications. The library allows creating simple email message with properties like From, To, Subject and body etc. Another great feature that library offers, is that changing email addresses to human-friendly names in an email message. Developers can easily construct email messages that can be transmitted to an SMTP server for delivery with ease. You can easily specify the email body encoding in ANSI, ASCII, Unicode, BigEndianUnicode,UTF-7, UTF-8 and send email message to single or multiple recipients.

How to Create New Email via .NET API?

string dataDir = RunExamples.GetDataDir_Email();

// Create a new instance of MailMessage class
MailMessage message = new MailMessage();

// Set subject of the message, Html body and sender information
message.Subject = "New message created by Aspose.Email for .NET";
message.HtmlBody = "This line is in bold. 

" + "This line is in blue color"; message.From = new MailAddress("from@domain.com", "Sender Name", false); // Add TO recipients and Add CC recipients message.To.Add(new MailAddress("to1@domain.com", "Recipient 1", false)); message.To.Add(new MailAddress("to2@domain.com", "Recipient 2", false)); message.CC.Add(new MailAddress("cc1@domain.com", "Recipient 3", false)); message.CC.Add(new MailAddress("cc2@domain.com", "Recipient 4", false)); // Save message in EML, EMLX, MSG and MHTML formats message.Save(dataDir + "CreateNewMailMessage_out.eml", SaveOptions.DefaultEml); message.Save(dataDir + "CreateNewMailMessage_out.emlx", SaveOptions.CreateSaveOptions(MailMessageSaveType.EmlxFormat)); message.Save(dataDir + "CreateNewMailMessage_out.msg", SaveOptions.DefaultMsgUnicode); message.Save(dataDir + "CreateNewMailMessage_out.mhtml", SaveOptions.DefaultMhtml);

Create & Manage Appointment via .NET Email API

Aspose.Email for .NET has provided complete support for working with appointments inside various .NET(C#, VB, ASP, J# etc.) applications. It allows software developers to load, create, read, modify and store appointments in ICS file format inside their own .NET applications. You can add the following information while creating an appointment location, summary, description, start date, end date, organizer and attendees. The appointment file can be opened in Microsoft Outlook or any software that can load an ICS file. You can easily add and read multiple events from ICS file with just couple of lines of C# code. It is also possible to create an appointment request in Draft mode. The library also supports setting the status of appointment attendees while formulating a reply message.

Create & Save Appointment to Disk in ICS Format via C# API


            // Create and initialize an instance of the Appointment class
            Appointment appointment = new Appointment(
                "Meeting Room 3 at Office Headquarters",// Location
                "Monthly Meeting",                      // Summary
                "Please confirm your availability.",    // Description
                new DateTime(2015, 2, 8, 13, 0, 0),     // Start date
                new DateTime(2015, 2, 8, 14, 0, 0),     // End date
                "from@domain.com",                      // Organizer
                "attendees@domain.com");                // Attendees

            // Save the appointment to disk in ICS format
            appointment.Save(dstEmail, AppointmentSaveFormat.Ics);
            Console.WriteLine("Appointment created and saved to disk successfully.");

Working with Outlook MSG Messages via C# API

Aspose.Email for .NET has included very powerful features that enables software developers to create and manipulate Outlook message (MSG) files inside their own C# applications. The library supports creating MSG messages, add attachments to messages, MSG message generation with an RTF body, save message as a draft, body compression support and so on. It is also very easy to modify the properties of an MSG file, such as To, From, Subject, Body, Attachments, etc. Another great feature of the library is loading, viewing and parsing the MSG file to display its contents.

Convert Outlook Message File (MSG) to TIFF Image via C# API

string dataDir = RunExamples.GetDataDir_KnowledgeBase();
MailMessage msg = MailMessage.Load(dataDir + "message3.msg", new MsgLoadOptions());

// Convert MSG to MHTML and save to stream
MemoryStream msgStream = new MemoryStream();
msg.Save(msgStream, SaveOptions.DefaultMhtml);
msgStream.Position = 0;

// Load the MHTML stream using Aspose.Words for .NET and Save the document as TIFF image
Document msgDocument = new Document(msgStream);
msgDocument.Save(dataDir + "Outlook-Aspose_out.tif", SaveFormat.Tiff);

Add & Manage Outlook Attachment via C# API

Aspose.Email for .NET makes it easy for software developers to create MSG messages with attachments using C#.NET API. The library has provided several important features for handling attachments inside outlook email messages, such as save attachment from outlook message, embedded messages as attachments, remove MSG attachments, reading embedded message from attachment, replace existing attachment with a new one, save attachments from digitally signed message and so on.  

How to Add Attachments to Emails via .NET API?

// Create an instance of MailMessage class
var eml = new MailMessage
{
    From = "sender@from.com",
    To = "receiver@to.com",
    Subject = "This is message",
    Body = "This is body"
};

// Load an attachment
var attachment = new Attachment("1.txt");

// Add Multiple Attachment in instance of MailMessage class and Save message to disk
eml.Attachments.Add(attachment);

eml.AddAttachment(new Attachment("1.jpg"));
eml.AddAttachment(new Attachment("1.doc"));
eml.AddAttachment(new Attachment("1.rar"));
eml.AddAttachment(new Attachment("1.pdf"));
eml.Save("AddAttachments.eml");