/// <summary> /// Enva un correo electronico /// </summary> /// <param name="subject"></param> /// <param name="html"></param> /// <param name="txt"></param> /// <param name="To"></param> /// <returns></returns> public static bool SendEmail(string subject, string html, string txt, string To) { SMTP sMTP = new SMTP(); sMTP = SMTP.GetSMTPSettings(); bool flag = false; string sMTPServer = sMTP.SMTPServer; int sMTPPort = sMTP.SMTPPort; string Email = PEDSS.Crypto.DecryptString(sMTP.Email); string Password = PEDSS.Crypto.DecryptString(sMTP.Password); bool sMTPSSL = sMTP.SMTPSSL; string displayName = sMTP.DisplayName; MailMessage mailMessage = new MailMessage(); MailAddress mailAddress = new MailAddress(Email, displayName, Encoding.UTF8); MailAddress mailAddress1 = new MailAddress(To); mailMessage.BodyEncoding = Encoding.UTF8; mailMessage.SubjectEncoding = Encoding.UTF8; mailMessage.HeadersEncoding = Encoding.UTF8; mailMessage.From = mailAddress; mailMessage.To.Add(mailAddress1); mailMessage.Subject = subject; AlternateView alternateView = AlternateView.CreateAlternateViewFromString(txt, Encoding.ASCII, "text/plain"); AlternateView alternateView1 = AlternateView.CreateAlternateViewFromString(html, Encoding.UTF8, "text/html"); mailMessage.AlternateViews.Add(alternateView); mailMessage.AlternateViews.Add(alternateView1); SmtpClient smtpClient = new SmtpClient() { Host = sMTPServer, Port = sMTPPort, Credentials = new NetworkCredential(Email, Password), EnableSsl = sMTPSSL }; try { smtpClient.Send(mailMessage); smtpClient.Dispose(); flag = true; } catch (Exception exception1) { Exception exception = exception1; PEDSS.Errorlog.Register(exception.Message, "Local", "SendEmail", exception.StackTrace, HttpContext.Current.Request.UserHostAddress, HttpContext.Current.Request.UserAgent); } return(flag); }