code:
// created on 17/05/2003 at 18.31 using System; using System.Web.Mail; namespace myMail { public class ClsMail { private string mTxtEmailTo; //Indirizzo destinatario private string mTxtEmailFrom;// Indirizzo mittente private string mTxtMailSubj; // oggetto della mail private string mTxtMailBody; //corpo della mail private string mTxtServerName; //server smtp public ClsMail() { Console.WriteLine ("Mail sender by the Nous"); Console.WriteLine ("-----------------------"); mTxtEmailFrom = ""; mTxtEmailTo = ""; } public string SmtpServer { set { mTxtServerName = value; SmtpMail.SmtpServer = value; } get { return mTxtServerName; } } public string EmailFrom { set { mTxtEmailFrom = value; } get { return mTxtEmailFrom; } } public string EmailTo { set { mTxtEmailTo = value; } get { return mTxtEmailTo; } } public string MailBody { set { mTxtMailBody = value; } get { return mTxtMailBody; } } public string MailSubject { set { mTxtMailSubj = value; } get { return mTxtMailSubj; } } public bool SendNow() { try { Console.WriteLine(); Console.WriteLine("Connessione a : {0}" , mTxtServerName); SmtpMail.Send (mTxtEmailFrom,mTxtEmailTo,mTxtMailSubj, mTxtMailBody); return true; } catch (Exception e) { Console.WriteLine("Errore nell'invio del messaggio : {0}" , e.Message ); return false; } } [STAThread] static void Main(string[] args) { ClsMail Smtp = new ClsMail(); Console.Write("Smtp server : "); Smtp.SmtpServer = Console.ReadLine(); Console.Write("Indirizzo mail del mittente : "); Smtp.EmailFrom = Console.ReadLine(); Console.Write("Indirizzo mail del destinatario : "); Smtp.EmailTo = Console.ReadLine(); Console.Write("Oggetto : "); Smtp.MailSubject = Console.ReadLine(); Console.Write("Testo : "); Smtp.MailBody = Console.ReadLine(); if (Smtp.SendNow()) { Console.WriteLine("Invio riuscito"); } else { Console.WriteLine("Invio fallito"); } } } }