This project is read-only.

SMTP Programming Reference

This document provides examples for all supported basic SMTP operations.

General Connection Handling
Supported Operations

Getting Started

In order to use the SMTP client we need to add all necessary dependencies to the project.

  • Crystalbyte.Equinox.Smtp.dll
  • Crystalbyte.Equinox.Mime.dll
  • Crystalbyte.Equinox.Core.dll

Finally we need to import the following namespaces.

using Crystalbyte.Equinox.Smtp;
using Crystalbyte.Equinox.Security;

We can now create an instance of the ImapClient.

var client = new SmtpClient();

Sending Messages

In order to send messages we need only to pass a valid message instance into the clients send method.

A valid message needs to have at least one sender (“From” property) and one recipient (“To” property). If multiple messages have to be send we can call the send method multiple times before closing the connection.

In order to monitor the upload progress, we can subscribe to the clients UploadProgressChanged event.

var message = new Message
Subject = "My message"
message.To.Add(new EmailContact("Peter", "");
message.From.Add(new EmailContact("Mary", "");

client.UploadProgressChanged += (sender, e) => Debug.WriteLine(string.Format("Progress: {0}%", e.Percentage));

Verifying Contacts

Although only very few servers support this capability it is possible to check the validity of a user/contact prior to sending the message.

The method Verify takes a user name and will return a list of matching addresses. Ideally only a single entry will be returned; If however  the query is ambiguous all potential contacts will be returned.

As an example I could call the method on the name “mary”, which would return “” if the server has the email address registered.

This is however only useful when querying mail servers for addresses stored locally on the server; A server will not be able to verify an email address not located in its data banks.

var response = client.Verify("mary");
if (response.IsOk) {
var hasMatches = response.Matches.Any();

Last edited Jul 2, 2011 at 6:48 PM by Krasshirsch, version 4


nkazakov Mar 24, 2016 at 8:46 AM 
And how add body of mail?

nkazakov Mar 24, 2016 at 8:46 AM 
Sending Messages example not working.

Object reference does not point to an instance of an object