sending email from contact page of website-VBForums
Results 1 to 1 of 1

Thread: sending email from contact page of website

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Jan 2011
    Location
    wv
    Posts
    21

    sending email from contact page of website

    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
    Last edited by sfzombie13; Jan 17th, 2013 at 07:47 PM. Reason: error in code posted
    < advertising link removed by moderator >

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.