看看我背后的电子邮件代码。
protected void Button1_Click(object sender, EventArgs e)
{
try
{
MailMessage mail = new MailMessage();
mail.To.Add("color.shadow@yahoo.com");
mail.From = new MailAddress("abc@gmail.com");
mail.Subject = "Reservation Status";
string Body = "Greeting from us." +
" You may view your booking details at your profile now." +
" Have a nice day." +
"Thank you.";
mail.Body = Body;
mail.IsBodyHtml = true;
SmtpClient smtp = new SmtpClient("localhost", 25);
smtp.Host = "smtp.gmail.com";
smtp.Credentials = new System.Net.NetworkCredential
(abc@gmail.com", "abcdef");
smtp.DeliveryMethod = SmtpDeliveryMethod.Network;
smtp.EnableSsl = true;
smtp.Send(mail);
Label1.Text = "Mail Send...";
}
catch (Exception ex)
{
Label1.Text = ex.Message;
}
}
在此代码中,我必须手动输入收件人电子邮件。我的问题是如何将电子邮件输入到文本框中,而不是mail.To.Add("color.shadow@yahoo.com");
提前谢谢!