ASP.Net4 aspx side der skal fungere som kontaktformular
Jeg har en ASP.Net4 aspx side der skal fungere som kontaktformularjeg får fejlen : txtTo er ikke deklareret
kan i hjælpe
<script language="VB" runat="server" >
Sub Page_Load()
If Not IsPostBack Then
lblMsg1.Text = ""
txtTo.Text = "xxx@yyy.dk" <===== Fejl
txtFrom.Text = ""
txtCc.Text = ""
txtBcc.Text = ""
txtSubject.Text = ""
txtBody.Text = ""
txtAttach.Text = ""
txtBodyEncoding.Text = Encoding.ASCII.EncodingName
txtBodyFormat.Text = "HTML"
txtPriority.Text = "Normal"
txtUrlContentBase.Text = ""
txtUrlContentLocation.Text = ""
' Name of relay mail server in your domain. '
txtMailServer.Text = "smtp.unoeuro.com"
End If
End Sub
Sub btnSubmit_Click(ByVal sender As Object, ByVal e As EventArgs)
Dim sTo As String, sFrom As String, sSubject As String, sBody As String
Dim sAttach As String, sCc As String, sBcc As String, sBodyEncoding As String
Dim sBodyFormat As String, sMailServer As String, sPriority As String
Dim sUrlContentBase As String, sUrlContentLocation As String
Dim iLoop1 As Integer
sTo = Trim("xxx@yyy.dk")
sFrom = Trim(txtFrom.Text)
sSubject = Trim(txtSubject.Text)
sBody = Trim(txtBody.Text)
sAttach = Trim(txtAttach.Text)
sCc = Trim(txtCc.Text)
sBcc = Trim(txtBcc.Text)
sBodyFormat = Trim("HTML")
sBodyEncoding = Trim("US-ASCII")
sPriority = Trim("Normal")
sUrlContentBase = Trim("")
sUrlContentLocation = Trim("")
sMailServer = Trim("smtp.unoeuro.com")
Dim MyMail As MailMessage = New MailMessage()
MyMail.From = sFrom
MyMail.To = sTo
MyMail.Subject = sSubject
MyMail.Body = sBody
MyMail.Cc = sCc
MyMail.Bcc = sBcc
MyMail.UrlContentBase = sUrlContentBase
MyMail.UrlContentLocation = sUrlContentLocation
Select Case txtBodyEncoding.Text
Case Encoding.UTF7.EncodingName : MyMail.BodyEncoding = Encoding.UTF7
Case Encoding.UTF8.EncodingName : MyMail.BodyEncoding = Encoding.UTF8
Case Else : MyMail.BodyEncoding = Encoding.ASCII
End Select
Select Case UCase(sBodyFormat)
Case "HTML" : MyMail.BodyFormat = MailFormat.Html
Case Else : MyMail.BodyFormat = MailFormat.Text
End Select
Select Case UCase(sPriority)
Case "HIGH" : MyMail.Priority = MailPriority.High
Case "LOW" : MyMail.Priority = MailPriority.Low
Case Else : MyMail.Priority = MailPriority.Normal
End Select
' Build an IList of mail attachments.
If sAttach <> "" Then
Dim delim As Char = ","
Dim sSubstr As String
For Each sSubstr In sAttach.Split(delim)
Dim myAttachment As MailAttachment = New MailAttachment(sSubstr)
MyMail.Attachments.Add(myAttachment)
Next
End If
SmtpMail.SmtpServer = sMailServer
SmtpMail.Send(MyMail)
lblMsg1.Text = "Mailen er sendt til " & MyMail.To
End Sub
Sub btnClear_Click(ByVal sender As Object, ByVal e As EventArgs)
lblMsg1.Text = ""
txtTo.Text = "xxx@yyy.dk"
txtFrom.Text = ""
txtSubject.Text = ""
txtBody.Text = ""
txtAttach.Text = ""
txtBcc.Text = ""
txtCc.Text = ""
txtBodyEncoding.Text = "US-ASCII"
txtBodyFormat.Text = "HTML"
txtPriority.Text = "Normal"
txtUrlContentBase.Text = ""
txtUrlContentLocation.Text = ""
txtMailServer.Text = "smtp.unoeuro.com"
btnSubmit.Text = "Submit"
End Sub
</script>