GemBox.Email is a .NET component that enables you to read, write, receive, and send emails from your .NET applications using one simple API.

Save Email in C# and VB.NET

The following example shows how to create an email message with two body versions, text and HTML, and save it to selected file format.

Screenshot
Save Screenshot

See the full code below, use Run Example to execute.

using GemBox.Email;
using GemBox.Email.Imap;
using GemBox.Email.Mime;
using GemBox.Email.Pop;
using GemBox.Email.Smtp;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Text;

class Sample
{
    [STAThread]
    static void Main(string[] args)
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

        // Create new message
        MailMessage message = new MailMessage(new MailAddress("sender@example.com", "Sender"),
                              new MailAddress("first.receiver@example.com", "First receiver"));

        // Add second receiver to CC and set subject
        message.Cc.Add(new MailAddress("carbon.copy@example.com", "Carbon Copy receiver"));
        message.Subject = "GemBox.Email .NET component save example";

        // Add HTML and text body
        message.BodyHtml = "<html>" +
                              "<body>" +
                                 "<p>Hi!<br/><br/>This message was created and saved with " +
                                    "<b>GemBox.Email .NET component</b>.<br/>" +
                                    "More info can be found at <a href=\"http://www.gemboxsoftware.com/\">" +
                                    "GemBox Software website</a>.<br/><br/>" +
                                    "Regards,<br/>" + 
                                    "GemBox" +
                                 "</p>" +
                              "</body>" +
                           "</html>";

        message.BodyText = "Hi!\r\n" +
                           "\r\n" +
                           "This message was created and saved with GemBox.Email .NET component.\r\n" +
                           "More info can be found at http://www.gemboxsoftware.com/.\r\n\r\n" + 
                           "Regards,\r\n" +
                           "GemBox";

        message.Save("Save.eml");
    }
}
Imports System.Globalization
Imports System.Text
Imports GemBox.Email
Imports GemBox.Email.Imap
Imports GemBox.Email.Mime
Imports GemBox.Email.Pop
Imports GemBox.Email.Smtp

Module Samples

    Sub Main()

        ' If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY")

        ' Create new message
        MailMessage message = new MailMessage(new MailAddress("sender@example.com", "Sender"),
                              new MailAddress("first.receiver@example.com", "First receiver"))

        ' Add second receiver to CC And set subject
        message.Cc.Add(New MailAddress("carbon.copy@example.com", "Carbon Copy receiver"))
        message.Subject = "GemBox.Email .NET component save example"

        ' Add HTML And text body
        message.BodyHtml = "<html>" &
                              "<body>" &
                                "<p>Hi!<br/><br/>This message was created and saved with " &
                                  "<b>GemBox.Email .NET component</b>.<br/>" &
                                  "More info can be found at <a href=""http://www.gemboxsoftware.com/"">" &
                                  "GemBox Software website</a>.<br/><br/>" &
                                  "Regards,<br/>" &
                                  "GemBox" &
                                "</p>" &
                              "</body>" &
                            "</html>"

        message.BodyText = "Hi!" & vbCrLf &
                           vbCrLf &
                           "This message was created and saved with GemBox.Email .NET component." & vbCrLf &
                           "More info can be found at http://www.gemboxsoftware.com/." & vbCrLf & vbCrLf &
                           "Regards," & vbCrLf &
                           "GemBox"

        message.Save("Save.eml")

    End Sub

End Module

Check next sample.