Sunteți pe pagina 1din 1

How To send an email with C#

Project Source Code :



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;
using System.Net.Mail;

namespace email
{
public partial class Form1 : Form
{

public Form1()
{
InitializeComponent();
}

private void send_Click(object sender, EventArgs e)
{
MailMessage msg = new MailMessage("your gmail
mail",textTo.Text,textSubject.Text,textmail.Text);
msg.IsBodyHtml = true;
SmtpClient sc = new SmtpClient("smtp.gmail.com",587);
sc.UseDefaultCredentials = false;
NetworkCredential cre = new NetworkCredential("your gmail mail",textpass.Text);//your
mail password
sc.Credentials = cre;
sc.EnableSsl = true;
sc.Send(msg);
MessageBox.Show("Mail Send");
}

}
}

S-ar putea să vă placă și