Send Email using Exchange Server and EWS protocol

GemBox.Email has a support for communication with the Microsoft Exchange Server using the Exchange Web Service (EWS) protocol.

The following example shows how you can connect to the Exchange Server and send an email with a basic body from your Console application by using C# or VB.NET code.

Screenshot of mail message sent with GemBox.Email
Mail message sent with GemBox.Email
using GemBox.Email;
using GemBox.Email.Exchange;

class Program
{
    static void Main()
    {
        // If using Professional version, put your serial key below.
        ComponentInfo.SetLicense("FREE-LIMITED-KEY");

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

        // Add additional receivers.
        message.Cc.Add(
            new MailAddress("third.receiver@example.com", "Third receiver"),
            new MailAddress("fourth.receiver@example.com", "Fourth receiver"));

        // Add subject and body.
        message.Subject = "Send Email in C# and VB.NET";
        message.BodyText = "Hi 👋,\n" +
            "This message was created and sent with GemBox.Email.\n" +
            "Read more about it on https://www.gemboxsoftware.com/email";

        // Create a new Exchange client and send an email message.
        var exchangeClient = new ExchangeClient("<HOST> (e.g. https://outlook.office365.com/EWS/Exchange.asmx)");
        exchangeClient.Authenticate("<USERNAME>", "<PASSWORD>");
        exchangeClient.SendMessage(message);
    }
}
Imports GemBox.Email
Imports GemBox.Email.Exchange

Module Program

    Sub Main()

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

        ' Create a new email message.
        Dim message As New MailMessage(
            New MailAddress("sender@example.com", "Sender"),
            New MailAddress("first.receiver@example.com", "First receiver"),
            New MailAddress("second.receiver@example.com", "Second receiver"))

        ' Add additional receivers.
        message.Cc.Add(
            New MailAddress("third.receiver@example.com", "Third receiver"),
            New MailAddress("fourth.receiver@example.com", "Fourth receiver"))

        ' Add subject and body.
        message.Subject = "Send Email in C# and VB.NET"
        message.BodyText = "Hi 👋," & vbLf &
            "This message was created and sent with GemBox.Email." & vbLf &
            "Read more about it on https://www.gemboxsoftware.com/email"

        ' Create a new Exchange client and send an email message.
        Dim exchangeClient = new ExchangeClient("<HOST> (e.g. https://outlook.office365.com/EWS/Exchange.asmx)")
        exchangeClient.Authenticate("<USERNAME>", "<PASSWORD>")
        exchangeClient.SendMessage(message)

    End Sub
End Module

Check next example or download examples from GitHub.