create static class and then add this method to in it and just pass the parameters from your page..
create folder attachment in solution explorer and then
uploaded
attachment using file upload control save in that folder..
Email em = new Email();
FileUpload1.SaveAs(Server.MapPath("~/Attachment/") + FileUpload1.FileName);
em.mail("smtp.gmail.com","xyz@gmail.com","password","aa@aa.com","body msg","subject","attachment name");
public void mail(string host, string fromaddress, string password, string toaddress, string body, string subject5, string attach)
{
SmtpClient smtp = new SmtpClient();
MailMessage msg = new MailMessage();
Attachment ament;
try
{
smtp.Host = host;
smtp.Credentials = new System.Net.NetworkCredential(fromaddress, password);
msg.From = new MailAddress(fromaddress, fromaddress);
msg.To.Add(toaddress);
if (attach != "")
{
string path = Server.MapPath("~/Attachment/") + attach;
ament = new Attachment(path);
msg.Attachments.Add(ament);
}
msg.Subject = subject5;
msg.IsBodyHtml = true;
msg.Body = body;
smtp.Send(msg);
}
catch (Exception ex)
{
Session["Mailerror"] = ex.Message;
}
}