Create Email in C# and VB.NET

GemBox.Email represents an email with a MailMessage object. This object provides properties for specifying or accessing the email's sender, recipient, subject, body and more. It's used for generating new or inspecting existing email messages.

The following example shows how you can create a simple message, with subject and body, in a standard MIME format.

Creating an email in C# and VB.NET
Screenshot of generated basic email
using GemBox.Email;

class Program
{
    static void 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"));

        // 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.%OutputFileType%");
    }
}
Imports GemBox.Email

Module Program

    Sub Main()

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

        ' Create new message.
        Dim message As 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.%OutputFileType%")
    End Sub
End Module

With GemBox.Email, you can easily create more advanced mail messages as well; for instance, you can check out our:

  • Html With Attachment example, for creating emails with HTML content, CSS styling, embedded images and attachments.
  • Header example, for creating emails with built-in or custom mail message headers.
  • Calendar example, for creating emails with calendars.

Want more?

Next example GitHub

Check the next example or select an example from the menu. You can also download our examples from the GitHub.


Like it?

Download Buy

If you want to try the GemBox.Email yourself, you can download the free version. It delivers the same performance and set of features as the professional version, but with some operations limited. To remove the limitation, you need to purchase a license.