Have a look at my email code behind.
看看我后面的电子邮件代码。
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;
}
}
In this code, I have to manually enter the receiver email. My question is how to get email entered onto text box instead of mail.To.Add("color.shadow@yahoo.com");
Thanks in advance!
在这个代码中,我必须手动输入收件人邮件。我的问题是如何让邮件进入文本框而不是mail.To.Add(“color.shadow@yahoo.com”);提前谢谢!
1 个解决方案
#1
1
Change mail.To.Add("color.shadow@yahoo.com");
to mail.To.Add(textBoxEmail.Text);
if you have created a textbox called textBoxEmail
.
改变mail.To.Add(“color.shadow@yahoo.com”);mail.To.Add(textBoxEmail.Text);如果你创建了一个名为textBoxEmail的文本框。
#1
1
Change mail.To.Add("color.shadow@yahoo.com");
to mail.To.Add(textBoxEmail.Text);
if you have created a textbox called textBoxEmail
.
改变mail.To.Add(“color.shadow@yahoo.com”);mail.To.Add(textBoxEmail.Text);如果你创建了一个名为textBoxEmail的文本框。