我正在尝试通过单击我的 vb 代码中的按钮发送电子邮件。代码工作正常;单击该按钮时,它将向mail.to.add 中指定的电子邮件地址发送一封电子邮件。如何将变量传递给它,以便电子邮件将根据文本字段中的电子邮件而不是 vb 代码中指定的电子邮件发送给用户?
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim mail As New MailMessage
mail.Subject = "Membership"
mail.To.Add("********")
mail.From = New MailAddress("**********")
mail.Body = "Congratulations! You have been approved as a member!"
Dim smtp As New SmtpClient("Smtp.gmail.com")
smtp.EnableSsl = True
smtp.Credentials = New System.Net.NetworkCredential("*******", "**********")
smtp.Port = "587"
smtp.Send(mail)
End Sub