Send email from Console Application
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net.Mail;
using System.Text;
using System.Threading.Tasks;
namespace SendMailConApp
{
class Program
{
static void Main(string[] args)
{
MailMessage email = new MailMessage();
SmtpClient client = new SmtpClient();
client.Port = 25;
client.Host = "127.0.0.1"; //use your smtp server name or IP address
client.Timeout = 10000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
//client.Credentials = new System.Net.NetworkCredential("user", "Password");
email.From = new MailAddress("from@server.com");
email.To.Add(new MailAddress("send@to.sk"));
email.Subject = "Send email C# test";
email.Body = "Sending email test console application";
client.Send(email);
}
}
}