Un poco de C#,JScript,VB, y CRM, Drupal, SQL , MSDCRM y MSDSL VBTools, developer, project lider, Social Media Activist, BlackBerry developer, telerik tools. (MCITP)
miércoles, 23 de mayo de 2012
Send email with c#
private void sendEmail()
{
//Declarando Variables
try
{
string From;
string To;
string Message;
string Subject;
System.Net.Mail.MailMessage Email;
//Aplicando los campos a cada variable
From = ;/*correo origen*/
To = ;/*correo destinatario*/
Message = ;/*Mensaje*/;
Subject =;/*Asunto*/
//Establesco El Email
Email = new System.Net.Mail.MailMessage(From, To, Subject, Message);
System.Net.Mail.SmtpClient smtpMail = new System.Net.Mail.SmtpClient("smtp.gmail.com");
Email.IsBodyHtml = false;
System.Net.Mail.Attachment attachment;
txtattach.Text = "";/*File Path*/;
attachment = new System.Net.Mail.Attachment(txtattach.Text.Trim());
Email.Attachments.Add(attachment);
smtpMail.EnableSsl = true;
smtpMail.UseDefaultCredentials = false;
smtpMail.Port = 25;
smtpMail.Credentials = new System.Net.NetworkCredential(/*USER*/,/*PASS*/);
//smtpMail.ClientCertificates.
ServicePointManager.ServerCertificateValidationCallback =
delegate(object s, X509Certificate certificate, X509Chain chain, SslPolicyErrors sslPolicyErrors)
{ return true; };
smtpMail.Send(Email);
attachment.Dispose();
MessageBox.Show("enviado con exito");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message.ToString());
}
}
Suscribirse a:
Enviar comentarios (Atom)
No hay comentarios:
Publicar un comentario