Send Mail with attachment
Add - using System.Net.Mail;
MailMessage mail = new MailMessage();//object created
//Setting From , To and CC
mail.To.Add(Textto.Text);
mail.From = new MailAddress(Textfrom.Text);
mail.Subject = "subject";
mail.Body = Textmessage.Text;
if (FileUpload2.HasFile == false)
{
}
else
{
mail.Attachments.Add(new Attachment(FileUpload2.FileContent, System.IO.Path.GetFileName(FileUpload2.FileName)));
}
mail.IsBodyHtml = true;// it will convert msg format in html
//smtp object
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential("email", "password");//email id & password
smtp.EnableSsl = true;// server security licence will true then only mail will send
smtp.Send(mail);//send function with mail object pass...which will send mail.
MailMessage mail = new MailMessage();//object created
//Setting From , To and CC
mail.To.Add(Textto.Text);
mail.From = new MailAddress(Textfrom.Text);
mail.Subject = "subject";
mail.Body = Textmessage.Text;
if (FileUpload2.HasFile == false)
{
}
else
{
mail.Attachments.Add(new Attachment(FileUpload2.FileContent, System.IO.Path.GetFileName(FileUpload2.FileName)));
}
mail.IsBodyHtml = true;// it will convert msg format in html
//smtp object
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential("email", "password");//email id & password
smtp.EnableSsl = true;// server security licence will true then only mail will send
smtp.Send(mail);//send function with mail object pass...which will send mail.