我有一个小问题,希望您可以提供帮助。
我有一个 Email.html 页面,它要求用户输入我也想向其发送电子邮件的电子邮件地址:
<section id="dialog" class="window">
<h1>Email Me <a href="#" class="close"/>Close</a></h1>
<p>Email Details To</p>
<input type="email" placeholder="email address" autofocus class="input- email" id="email">
<p id="email-entry" class="error disp-none">Please enter an email address</p>
<p id="email-valid" class="error disp-none">Please enter a valid email address</p>
<input type="button" value="Send" id="btn-send">
我有一个 aspx.vb 文件,我希望它能够“处理”电子邮件:
Imports System.Net.Mail
Partial Class ContactUs
Inherits System.Web.UI.Page
Protected Sub SendMails_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles SendMails.Click
Dim FromPersonName As String = FromName.Text
Dim FromPersonEmail As String = “sales@test.co.uk”
Dim FromPersonContactNumber As String = FromContactNumber.Text
Dim EmailSubject As String = Subject.Text
Dim ToAddress As String = email.input
'(1) Create the MailMessage instance
Dim mm As New MailMessage(FromEmail.Text, ToAddress)
'(2) Assign the MailMessage's properties
mm.Subject = Subject.Text
mm.Body = "Thank you for your enquiry. A member of our team will contact you shortly.”
mm.IsBodyHtml = False
'(3) Create the SmtpClient object
Dim smtp As New SmtpClient
'(4) Send the MailMessage (will use the Web.config settings)
smtp.Send(mm)
EmailSentForm.Visible = True
SendMails.Visible = False
End Sub
End Class
最后,访问我的服务器的 web.config 文件:
<system.net>
<mailSettings>
<smtp>
<!-- <network host="yourRELAYSERVERHOSTNAME" port="yourPORTNUMBER" userName="yourUSERNAME" password="yourPASSWORD" /> -->
</smtp>
</mailSettings>
</system.net>
如何将这些文件集成在一起(如果可能),所以当用户在 .html 页面中输入电子邮件地址时,会调用 .aspx.vb 脚本和 web.config?
对于我想要实现的目标,是否有更简单的解决方案?
任何帮助表示赞赏,谢谢。