using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net.Mail;
namespace WindowsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
SmtpClient SmtpServer = new SmtpClient(
"smtp.gmail.com");
mail.From = new MailAddress("kamacac87@gmail.com");
mail.To.Add("cac.kamaraju@gmail.com");
mail.Subject = "Test Mail";
mail.IsBodyHtml = true;
string htmlBody;
htmlBody = "Hello P.Kamaraju<br> Write some HTML code here";
mail.Body = htmlBody;
SmtpServer.Port = 587;
SmtpServer.Credentials = new
System.Net.NetworkCredential("kamacac87", "yakubhai");
SmtpServer.EnableSsl = true;
SmtpServer.Send(mail);
MessageBox.Show("Mail has been sent Successfully.");
}
catch (Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
}
}
I hope it helps you.