Guys I am stuck with a problem and want your genuine suggestion..
Actually the problem is that i am trying to send a mail using c#.net..
There is no issues while sending mail but when i try to include an attachment with it is not taking the path of the concerned directory.. But when i am attaching the file from the root directory here i have my codes it is working absolutely well..
Plz look at the code below and give some suggestion to rectify the problem..
protected void btnSend_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add(txtTo.Text);
mail.From = new MailAddress("orangesoftech2012@gmail.com");
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
System.Net.Mail.Attachment attachment;
attachment = new System.Net.Mail.Attachment(FileUpload1.FileName);
mail.Attachments.Add(attachment);
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient();
smtp.Host = "smtp.gmail.com"; //Or Your SMTP Server Address
smtp.Credentials = new System.Net.NetworkCredential
("orangesoftech2012@gmail.com", "orangeorange");
//Or your Smtp Email ID and Password
smtp.EnableSsl = true;
smtp.Send(mail);
Response.Write("<script language='javascript'>alert('MAIL SENT');</script>");
Response.Write("<script language='javascript'>alert('Thank You for using VishalMail');</script>");
}
catch (Exception ex)
{
labelError.Text = ex.Message;
}
}