public wappSpValidateMail_Result3 SendMailUser(string usermail) { wappSpValidateMail_Result3 list = null; string mailServer = ConfigurationManager.AppSettings["MailServer"]; string MailServerPass = ConfigurationManager.AppSettings["MailServerPass"]; //string mailServer = ConfigurationManager.AppSettings["GDataUserName"]; //string MailServerPass = ConfigurationManager.AppSettings["GDataUserPassword"]; using (var entity = new db_SeguimientoProtocolo_r2Entities()) { list = entity.wappSpValidateMail(usermail).ToList().First(); if (list.IdUsuario != null && list.IdSesion == null) { string i = "Usuario no encontrado"; } else { try { MailMessage mail = new MailMessage(); SmtpClient SmtpServer = new SmtpClient("smtp.gmail.com"); mail.From = new MailAddress(mailServer); mail.To.Add(usermail); mail.Subject = "RECUPERACIÓN DE CONTRASEÑA"; mail.IsBodyHtml = true; string htmlBody; htmlBody = "<div>" + "<div>" + "<table style='width:100%;font-family:Tahoma'>" + "<tbody>" + "<tr><td colspan='2'>" + "<img src='https://ci5.googleusercontent.com/proxy/Rh3eBT1tluC2xtk-BEX6lI8qDUdjUvEpLiPdethYJoWe8F-hIDDk-pswK7p2MYxAHBsZTJ1pDiXNY-fjgMmlxqE=s0-d-e1-ft#http://www.cna.gob.mx/Imagenes/semarnat.jpg' width='100%'>" + "</td></tr>" + "<tr><td colspan='2'><hr>" + "<br>" + "Usted a solicitado un cambio de contraseña." +"<br> <br></td>" + "</tr><tr>" + "<td style='text-align:center;background-color:#507fe0;color:White;font-family:Tahoma;font-size:large' colspan='2'>" + "ACTUALIZACIÓN DE CONTRASEÑA" + "</td></tr>" + "<tr><td style='text-align:right' colspan='2'></td></tr>" + "<tr>" +"<td style='width:20%;text-align:right;vertical-align:top'>" + "Url:" +"</td>" +"<td>" + "<a href='" + "http://devinmservices.com/lluviasadmdev/RecovPass/index.html#/" + "Key:" + list.IdSesion +"'>" + "http://devinmservices.com/lluviasadmdev/RecovPass/index.html#/" + "Key:" + list.IdSesion +"</a>" + "</td>" +"</tr>" + "<tr>" + "<td style='width:20%;text-align:right;vertical-align:top'>" + "Email:" + "</td>" + "<td>" + usermail + "</td>" + "</tr>" + "<tr>" + "<td style='width:20%;text-align:right;vertical-align:top'>" + "Llave Unica:" + "</td>" + "<td>" + list.IdSesion + "</td>" + "</tr>" +"</tbody></table>" + "</div><div class='yj6qo'></div>" + "</div>"; mail.Body = htmlBody; SmtpServer.Port = 587; SmtpServer.Credentials = new System.Net.NetworkCredential(mailServer, MailServerPass); SmtpServer.EnableSsl = true; SmtpServer.Send(mail); } catch (Exception ex) { var err = ex.Message; } } } return list; }