using System; using System.Web.Mail; namespace PlanoSimple { /// <summary> /// /// </summary> class PlanoSimple { static bool SendPlainTextEMail(string strFrom, string strTo, string strSubject, string strBody) { bool bRet = true; MailMessage msg = new MailMessage(); try { msg.From = strFrom; msg.To = strTo; msg.Subject = strSubject; msg.Body = strBody; SmtpMail.Send(msg); } catch(Exception) { bRet = false; } return bRet; } /// <summary> /// main de la aplicación. /// </summary> [STAThread] static void Main(string[] args) { string strFrom = "test@origen.com"; string strTo = "test@destino.com"; string strSubject = "Titulo"; string strBody = "Contenido del E-Mail"; bool bSuccess = false; Console.WriteLine("Enviando E-Mail a:" + strTo); bSuccess = SendPlainTextEMail(strFrom, strTo, strSubject, strBody); if(bSuccess) { Console.WriteLine("Mail enviado con éxito"); } else { Console.WriteLine("Ocurrio un fallo al enviar el e-mail"); } Console.ReadLine(); } } } Fuente 1. Enviando eMail de texto plano, usando un servidor de correo local |