public void mandar_mail()
{
System.Net.Mail.MailMessage correo = new System.Net.Mail.MailMessage();
correo.From = new System.Net.Mail.MailAddress("
[email protected] m");
correo.To.Add("
[email protected]");
correo.Subject = "Asunto prueba"; //txtAsunto.Text;
correo.Body = "Hola mundo!"; //txtTexto.Text;
correo.IsBodyHtml = false;
correo.Priority = System.Net.Mail.MailPriority.Normal;
System.Net.Mail.Attachment attachment = new System.Net.Mail.Attachment(Server.MapPath("adjunto .txt"));
//lo añadimos al mail
correo.Attachments.Add(attachment);
System.Net.Mail.SmtpClient smtp = new System.Net.Mail.SmtpClient();
//smtp.Host = "localhost";
smtp.Host = "mail.hotmail.com";
try
{
smtp.Send(correo);
Response.Write("Mensaje enviado satisfactoriamente");
}
catch (Exception ex)
{
Response.Write("ERROR: " + ex.Message);
}
}