using System.Web.Mail;
MailMessage mail = new MailMessage();
try
{
mail.To = "vijayfreak@yahoo.co.in";
mail.From = "raja@gmail.com";
mail.Subject = "Task Reply";
mail.Body = "hai how rloloo u ";
mail.Priority = MailPriority.High;
//.SmtpServer = System.serv
SmtpMail.Send(mail);
Response.Write("suecess");
}
catch (Exception ex)
{
Response.Write(ex.Message + " :" + ex.StackTrace);
}
//sending mail with attachment
string strdir = "C:\\temp\\";
string strfilename = Path.GetFileName(FileUpload1.PostedFile.FileName);
FileUpload1.PostedFile.SaveAs(strdir + strfilename);
MailMessage mail_message = new MailMessage();
mail_message.To = TextBox1.Text.ToString();
mail_message.From = TextBox2.Text.ToString();
mail_message.Subject = TextBox3.Text.ToString();
mail_message.Attachments.Add(new MailAttachment(strdir+strfilename));
//mail_message.Attachments.Add(new MailAttachment(strdir+strfilename));
mail_message.Body = "test";
SmtpMail.Send(mail_message);
FileInfo f = new FileInfo(strdir + strfilename);
f.Delete();
No comments:
Post a Comment