Already registered? Log in
Please make sure that you have included all the required namespaces.
Please change the following in this script:
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);
}
}
}
}
Try SMTP2GO free for as long as you like:
Try SMTP2GO Free → Paid plans available for over 1,000 emails/month.