Design:
----------------------
using System;
using System.Net;
using System.Net.Mail;
public partial class _Default : System.Web.UI.Page
{
MailMessage msgobj;
protected void btnSend_Click(object sender, EventArgs e)
{
SmtpClient serverobj = new SmtpClient();
serverobj.Credentials = new NetworkCredential(TextBox1.Text, TextBox2.Text);
serverobj.Port = 587;
serverobj.Host = "smtp.gmail.com";
serverobj.EnableSsl = true;
msgobj = new MailMessage();
msgobj.From = new MailAddress(TextBox1.Text, "email demo", System.Text.Encoding.UTF8);
msgobj.To.Add(TextBox3.Text);
msgobj.Priority = MailPriority.High;
msgobj.Subject = TextBox4.Text;
msgobj.Body = TextBox5.Text;
msgobj.Attachments.Add(new Attachment(MapPath("accept.jpg")));
msgobj.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure;
serverobj.Send(msgobj);
LabelOutput.Text = "mail sent successfully...!";
}
}
------------------
Output: