try
{
string str = "";
HttpFileCollection fileCollection = Request.Files;
for (int i = 0; i < fileCollection.Count; i++)
{
HttpPostedFile uploadfile = fileCollection[i];
string fileName = Path.GetFileName(uploadfile.FileName);
// fileName = GetUniqueFileName(fileName);
if (uploadfile.ContentLength > 0)
{
uploadfile.SaveAs(Server.MapPath("~/Upload/MailAttachments/") + fileName);
str += fileName + ",";
//string path = Server.MapPath("~/Upload/MailAttachments/") + fileName;
//uploadfile.SaveAs(Server.MapPath(path));
//str = path;
}
}
string BodyText = "";
BodyText = "<b>Dear User,</b><br><br>";
BodyText = BodyText + "Following are the details of the patient who has requested for a appointment you through your website 'ahms.co.in'<br /><br />";
BodyText = BodyText + "Patient Name: " + txtPatient.Text + "<br>";
BodyText = BodyText + "Email : " + txtEmail.Text + "<br>";
BodyText = BodyText + "Mobile Number: " + txtMobile.Text + "<br>";
BodyText = BodyText + "Health issues: " + txthealthissue.Text + "<br> <br />";
BodyText = BodyText + "Appointment Date: "+txtDate.Text+"<br/>";
BodyText = BodyText + "Time Slot choosed: " + ddtimeslot.Text + "<br/>";
BodyText = BodyText + "Thanks,<br />Web Admin";
//arif.khan@dynamicconsultant.net info@ahms.co.in
if (obj.SendMail("info@ahms.co.in", "mail@ahms.co.in ", "Request for Appointment from : ahms.co.in", BodyText, str) == "mailsend")
{
lblMsg.Text = "Thankyou!!We'll get back to you soon";
Reset();
}
else
{
lblMsg.Text = "Mail server encounter an error.Try again.";
}
}
public String SendMail(String MailTo, String MailFrom, String Subject, String MailBody, string pAttachmentPath)
{
try
{
MailMessage msg = new MailMessage();
MailAddress mailaddressfrom = new MailAddress(MailFrom);
MailAddress mailaddressTo = new MailAddress(MailTo);
msg.From = mailaddressfrom;
msg.To.Add(mailaddressTo);
msg.Subject = Subject;
msg.Body = MailBody;
msg.IsBodyHtml = true;
if (pAttachmentPath.Trim() != "")
{
System.Net.Mail.Attachment MyAttachment = new System.Net.Mail.Attachment(pAttachmentPath);
msg.Attachments.Add(MyAttachment);
msg.Priority = System.Net.Mail.MailPriority.High;
}
SmtpClient objSmtp = new SmtpClient();
//objSmtp.Host = "mail.nissindia.com";
objSmtp.Send(msg);
return "mailsend";
}
catch (Exception ex)
{
return ex.ToString();
}
}
the conrol jump in catch block or showing error file could not be found, how to remove it please help.
Thanks in adv.