Create Email in C# and VB.NET

Composing email messages is simple and straightforward with the GemBox.Email .NET component. The following example shows how to create a mail message, set subject, text body and how to save it to hard disk in standard MIME format.

Screenshot
Create Message Screenshot

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

using GemBox.Email;
using GemBox.Email.Mime;
using GemBox.Email.Smtp;
using System;
using System.Collections.Generic;

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"));

        // Set subject and text body
        message.Subject = "Test email message with text body";
        message.BodyText = "This is a test message with text body.";

        message.Save("Create Message.eml");
    }
}
Imports GemBox.Email
Imports GemBox.Email.Mime
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
        Dim message = New MailMessage(New MailAddress("sender@example.com", "Sender"),
                      New MailAddress("first.receiver@example.com", "First receiver"))

        ' Set subject And text body
        message.Subject = "Test email message with text body"
        message.BodyText = "This is a test message with text body."

        message.Save("Create Message.eml")

    End Sub

End Module