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; // add this inorder to send mail
namespace email
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
MailMessage m = new MailMessage();
m.From = new MailAddress("mail id");
m.To.Add(textBox1.Text);
m.Body = "hhhhhhhhhadjfsjdfoijfosdijfoisdjfoisdhfisdhfsiodhfoishd";
m.Subject = textBox2.Text;
SmtpClient sc = new SmtpClient("smtp.gmail.com", 587);
sc.EnableSsl = true;
sc.Credentials = new System.Net.NetworkCredential("your mailid", "password");
try
{
sc.Send(m);
MessageBox.Show("message has sended");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
// finally
//{
//}
}
}
}
No comments:
Post a Comment