C# SMTP Integration Guide

Minimum code that you need to integrate Mailazy with your .Net application


You need to complete these given prerequisites, you can skip the step if you have already completed.

  1. Sign up for a Mailazy account.
  2. Complete Domain Authentication.
  3. Generate the Mailazy Access Key

Integrate Mailazy with C#

Start Sending mail using the code provided below:

using System.Net;
using System.Net.Mail;
class Example
    static void Main(string[] args)
        var mail = new MailMessage();

        //set the addresses
        mail.From = new MailAddress("sender@example.com", "sender");

        //set the content
        mail.Subject = "Sending with Mailazy";

        //set the plain text part
        var plainView = AlternateView.CreateAlternateViewFromString("Hello World!", System.Text.Encoding.UTF8, 
        //then set the html part
        var htmlView = AlternateView.CreateAlternateViewFromString("<b>Hello World!</b>", 
            System.Text.Encoding.UTF8, "text/html");

        //send the message
        var smtp = new SmtpClient("smtp.mailazy.com", 587);
        smtp.UseDefaultCredentials = false;
        smtp.Credentials = new NetworkCredential("<access_key>", "<access_secret>");
        smtp.EnableSsl = true;