Log In

Step 1

Please make sure that you have included all the required namespaces.

Step 2

Please change the following in this script:

  • sender@example.com: the sender’s email address.
  • recipient@example.com: the recipient’s email address.
  • USERNAME: your SMTP2GO username.
  • PASSWORD: your SMTP2GO password.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net.Mail;
using System.Net.Mime;
using System.Net;

namespace smtp2goMail
{
class Program
{
static void Main(string[] args)
{
try
{
var mail = new MailMessage();
var client = new SmtpClient("mail.smtp2go.com", 2525) //Port 8025, 587 and 25 can also be used.
{
Credentials = new NetworkCredential("USERNAME", "PASSWORD"),
EnableSsl = true
};
mail.From = new MailAddress("sender@example.com");
mail.To.Add("recipient@example.com");
mail.Subject = "Your Subject";
var plainView = AlternateView.CreateAlternateViewFromString("This is a text message", null, "text/plain");
var htmlView = AlternateView.CreateAlternateViewFromString("This is a html message", null, "text/html");
mail.AlternateViews.Add(plainView);
mail.AlternateViews.Add(htmlView);
client.Send(mail);
Console.WriteLine("Sent");
Console.ReadLine();
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

Ready for better email delivery?

Try SMTP2GO free for as long as you like:

Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.