You are on page 1of 2

using System;

using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;

namespace e_marketing
{
public partial class Form1 : Form
{
public Form1()

InitializeComponent();

private void button5_Click(object sender, EventArgs e)


{
string Adjunto=@"c:/x/clientes.xlsx";
string Servidor = "smtp.gmail.com";
int Puerto = 587;
MailMessage objMail;
objMail = new MailMessage();
objMail.From = new MailAddress("tuemail@gmail.com","Nombre");

//Remitente
objMail.To.Add("fernando.campos@udo.mx"); //Email a enviar
//objMail.CC.Add("lscfccbatamote@hotmail.com"); //Email a enviar copia
//objMail.Bcc.Add("oculto@destino.com"); //Email a enviar oculto
objMail.Subject = "Invitacin y adjunto";
objMail.Body = "Estimado Sr. etc etc";
objMail.IsBodyHtml = true; //Formato Html del email
objMail.Attachments.Add(new Attachment(Adjunto));
SmtpClient SmtpMail = new SmtpClient();
SmtpMail.Host = Servidor; //el nombre del servidor de correo
SmtpMail.Port = Puerto; //asignamos el nmero de puerto
SmtpMail.EnableSsl = true; //Esto es para que vaya a travs de SSL que es obligatorio con GMail
SmtpMail.Credentials = new System.Net.NetworkCredential ("tuemail@gmail.com","tuclave");
SmtpMail.Send(objMail); //Enviamos el correo
}
}
}

Fernando Campos Camacho UdeO-Gml 2012

You might also like