我经历了你的"C#的ASP.NET发送邮件"的例子..
调试通过Visual Studio,我没有收到任何错误。邮件发送确定,但在此上传到我们的在线网站,我得到一个错误。你可以给我做什么想法?
我已经写在我的cs文件代码:
任何人都可以在我的代码发现可疑的东西吗?
protected void submit_Click(object sender, EventArgs e)
{
String body = "<html><body>";
// (MRB Edit
// Deleted lots of these: body += "";
// as they weren't doing anything useful
body += " Name of Organization : " + name_organization.Text.Trim() + "Address: " + address.Text.Trim() + "Tel. No.:" + tele_no.Text.Trim() + "Fax : " + fax_no.Text.Trim() + " Mobile : " + mobile_no.Text.Trim() + "Company Email :" + company_email.Text.Trim() + "Contact Person : " + contact_person.Text.Trim() + "Accident Description :" + other_information0.Text.Trim() + "Contact Person : " + level_participants.Text.Trim() + "Picture of the Exact Location :" + object_training.Text.Trim() + "Any other information :" + other_information.Text.Trim() + "";
body += "</body></html>";
string attach3 = null;
string strFileName = null;
MailMessage mail = new MailMessage();
mail.From = new MailAddress("XXXXX.XXXX@ask-ehs.com");
mail.To.Add("XXXXX.XXXX@ask-ehs.com");
mail.Subject = name_organization.Text;
mail.Body = body;
mail.IsBodyHtml = true;
mail.Priority = MailPriority.High;
if (fileImage.PostedFile != null)
{
HttpPostedFile attFile = fileImage.PostedFile;
int attachFileLength = attFile.ContentLength;
if (attachFileLength > 0)
{
strFileName = Path.GetFileName(fileImage.PostedFile.FileName);
fileImage.PostedFile.SaveAs(Server.MapPath(strFileName));
Attachment attach = new Attachment(Server.MapPath(strFileName));
mail.Attachments.Add(attach);
attach3 = strFileName;
}
}
SmtpClient smtp = new SmtpClient("127.0.0.1");
smtp.Send(mail);
clear();
Response.Redirect("enquiry_accident_scenario_thanks.html");
}
感谢您的考虑!