using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// Add EASendMail namespace
using EASendMail;
namespace EmailList
{
class Program
{
static void Main(string[] args)
{
SmtpMail oMail = new SmtpMail("TryIt");
SmtpClient oSmtp = new SmtpClient();
// Set sender email address, please change it to yours
oMail.From = "from email";
// Set recipient email address, please change it to yours
oMail.To = "to email";
// Set email subject
oMail.Subject = "Cocktail Invite";
// Your SMTP server address
SmtpServer oServer = new SmtpServer("smtp.gmail.com");
// User and password for ESMTP authentication, if your server doesn't require
// User authentication, please remove the following codes.
oServer.User = "mymail";
oServer.Password = "mypass";
// If your smtp server requires implicit SSL connection on 465 port, please add this line
oServer.Port = 465;
oServer.ConnectType = SmtpConnectType.ConnectSSLAuto;
try
{
// Import html body and also import linked image as embedded images.
oMail.ImportHtmlBody("C:\\Users\\COMPUTER2\\Desktop\\test.htm",
ImportHtmlBodyOptions.ImportLocalPictures | ImportHtmlBodyOptions.ImportCss);
oMail.SaveAs("C:\\Users\\COMPUTER2\\Desktop\\test.htm", true);
Console.WriteLine("start to send email ...");
oSmtp.SendMail(oServer, oMail);
Console.WriteLine("email was sent successfully!");
}
catch (Exception ep)
{
Console.WriteLine("failed to send email with the following error:");
Console.WriteLine(ep.Message);
}
}
}
}