Here’s a sample code to send email via SMTP using C#.
How to Send e-mail via SMTP using C# ?
using System.Net.Mail;
namespace AbundantcodeCsharpSample
{
class Program
{
static void Main(string[] args)
{
MailMessage mailobj = new MailMessage("[email protected]", "[email protected]");
SmtpClient clientobj = new SmtpClient();
clientobj.Port = 25;
clientobj.DeliveryMethod = SmtpDeliveryMethod.Network;
clientobj.UseDefaultCredentials = false;
clientobj.Host = "smtp.google.com";
mailobj.Subject = "Test email subject from abundantcode.com";
mailobj.Body = "Mail body";
clientobj.Send(mailobj);
}
}
}
Leave a Reply