Quantcast
Channel: VBForums - ASP, VB Script
Viewing all articles
Browse latest Browse all 681

sending email from contact page of website

$
0
0
i have been trying to figure out how to send an email message from user input on a contact page of my website, and am using visual studio 2010. ideally, the user would input their name, email address, phone number, and a short description in text boxes on a contact page, and when they click the submit button, it generates an email message to me. i have been reading and trying various things for two days now, and have finally gotten the code right, but when i publish the website, i get the following build errors: 'MailMessage.From' is not accessible in this context because it is 'Friend' and one for MailMessage.To, MailMessage.Subject, MailMessage.Body and SMTPClient.Credentials all saying the same thing. the code i have is
Partial Class contact
Inherits System.Web.UI.Page

Dim mMailSettings As System.Net.Configuration.MailSettingsSectionGroup

Dim mPort As Integer = mMailSettings.Smtp.Network.Port
Dim mHost As String = mMailSettings.Smtp.Network.Host
Dim mPassword As String = mMailSettings.Smtp.Network.Password
Dim mUsername As String = mMailSettings.Smtp.Network.UserName
Sub Authenticate()
'create the mail message
Dim mail As New MailMessage()

'set the addresses
mail.From = New MailAddress("%TextBox3%")
mail.To.Add("contact@kitswv.com")

'set the content
mail.Subject = "contact"
mail.Body = "%TextBox4%"

'send the message
Dim smtp As New SmtpClient("relay-hosting.secureserver.net")

'to authenticate we set the username and password properites on the SmtpClient
smtp.Credentials = NetworkCredential("myusername", "password")
smtp.Send(mail)
End Sub 'Authenticate

Private Function NetworkCredential(ByVal p1 As String, ByVal p2 As String) As Object
Throw New NotImplementedException
End Function

End Class

i thought that the 'Friend' part of the error meant that i was not able to create an instance directly, it had to be done and sent back. that's what i'm reading anyway, i am new to this. any help is appreciated

Viewing all articles
Browse latest Browse all 681

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>