实际上,我现在使用ASP C#发送电子邮件,内容类似于:
protected void Page_Load(object sender, EventArgs e){ if (Request.Form.Count > 0) { string formEmail = ""; string fromEmail = "from@email.com"; string defaultEmail = "default@email.com"; string sendTo1 = ""; int x = 0; for (int i = 0; i < Request.Form.Keys.Count; i++) { formEmail += "<strong>" + Request.Form.Keys[i] + "</strong>"; formEmail += ": " + Request.Form[i] + "<br/>"; if (Request.Form.Keys[i] == "Email") { if (Request.Form[i].ToString() != string.Empty) { fromEmail = Request.Form[i].ToString(); } formEmail += "<br/>"; } } System.Net.Mail.MailMessage myMsg = new System.Net.Mail.MailMessage(); SmtpClient smtpClient = new SmtpClient(); try { myMsg.To.Add(new System.Net.Mail.MailAddress(defaultEmail)); myMsg.IsBodyHtml = true; myMsg.Body = formEmail; myMsg.From = new System.Net.Mail.MailAddress(fromEmail); myMsg.Subject = "Sent using Gmail Smtp"; smtpClient.Host = "smtp.gmail.com"; smtpClient.Port = 587; smtpClient.EnableSsl = true; smtpClient.UseDefaultCredentials = true; smtpClient.Credentials = new System.Net.NetworkCredential("testing@gmail.com", "pward"); smtpClient.Send(defaultEmail, sendTo1, "Sent using gmail smpt", formEmail); } catch (Exception ee) { debug.Text += ee.Message; } }}这是使用gmail作为smtp邮件发件人的示例。这里不需要其中的某些内容,但这是我的使用方式,因为我敢肯定,以相同的方式有更有效的方法。



