· 8 years ago · Mar 09, 2018, 01:42 AM
1if (Consulta == "Aprobado") {
2 MailMessage email = new MailMessage();
3 email.To.Add(new MailAddress("xxxxxxxxx@gmail.com"));
4 email.From = new MailAddress("xxxxxxxxxxx@gmail.com");
5 email.Subject = "Asunto(Correo Prueba)";
6 email.Body = "Contenido Prueba";
7 email.IsBodyHtml = true;
8 email.Priority = MailPriority.Normal;
9
10 SmtpClient smtp = new SmtpClient();
11 smtp.Host = "gmail.com";
12 smtp.Port = 465;
13 smtp.EnableSsl = false;
14 smtp.UseDefaultCredentials = false;
15 smtp.Credentials = new NetworkCredential("xxxxxxxxxxx@gmail.com", "xxxxxxxxx");
16
17 try {
18 smtp.Send(email);
19 email.Dispose();
20 this.Page.Response.Write("<script language='JavaScript'>window.alert('" +
21 "Correo electrónico fue enviado satisfactoriamente" + "');</script>");
22 } catch (Exception ex) {
23 this.Page.Response.Write("<script language='JavaScript'>window.alert('" +
24 "Error enviando correo" + "');</script>");
25 this.Page.Response.Write("<script language='JavaScript'>window.alert('" +
26 ex.Message.ToString() + "');</script>");
27 }
28
29}