aspx contact email form

i just took over an website and i am not familiar with aspx and such. this is the code on one of the pages. this is the only place i could find where to change the email address to where it the from sends the data. I have changed it but i am still not recieving the emails...any help would be appreciated.
Partial Class contact_contact_form
    Inherits System.Web.UI.Page

  Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
    If Not IsPostBack Then
      txtEmail.Text = ""
      txtName.Text = ""
      txtComment.Text = ""
    End If

    lblYear.Text = DatePart(DateInterval.Year, Date.Now)
  End Sub



  Protected Sub btnBook_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBook.Click
    If Page.IsValid Then
      Call SendEmail()
      Call ClearFields()
      lblInfo.Visible = True
      lblInfo.Text = "<p style='color:red;'>Your email was sent successfully! Thank you for contacting Vintage Motor Club.</p>"
    End If
  End Sub

  Private Sub ClearFields()

    txtEmail.Text = ""
    txtName.Text = ""
    txtComment.Text = ""

  End Sub

  Private Sub SendEmail()

    Dim strBody As String = "You have received an email from the Vintage Motor Club website contact form. The details are below." & vbCrLf & vbCrLf
    strBody &= "Date of Contact: " & Date.Today.ToShortDateString & vbCrLf
    strBody &= "Name: " & txtName.Text.Trim & vbCrLf
    strBody &= "Email: " & txtEmail.Text.Trim & vbCrLf
    strBody &= "Question/Comment: " & txtComment.Text.Trim & vbCrLf & vbCrLf

    'to Admin
    Dim msg As New MailMessage
    With msg
      .To.Add(New MailAddress("kroberts@keifersdesign.com", "Administrator"))
      .From = New MailAddress(txtEmail.Text.Trim, txtName.Text.Trim)
      .Subject = "Contact Form Submission - Vintage Motor Club"
      .Body = strBody
    End With

    Call AsyncMail.SendAsyncEmail(msg)


  End Sub

End Class

Open in new window

chefkeiferAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

lucius_theCommented:
Your code calls the "SendAsyncEmail" shared method of the "AsyncEmail" class, and gives the "MailMessage" type parameter. You have to find this method and see what happens in there. You will likely find what SMTP server it's hardcoded to use and you can then check if they the correct login data is provided to SMTP.

Just paste the code from "AsyncMail.SendAsyncEmail" if you will need more help.
chefkeiferAuthor Commented:
I found a file that was name this AsyncMail.vb with the following code..

i know nothing about this...so thanks for you help
Imports Microsoft.VisualBasic
Imports System.Net.Mail
Imports System.Web.HttpContext

Public Class AsyncMail

   ''' <summary>
   ''' Retrieves the SMTP host
   ''' </summary>
   ''' <returns>A string value containing the SMTP host</returns>
   ''' <remarks></remarks>
   Public Shared Function GetMailServer() As String

      Dim strMailHost As String = "localhost"

      Dim strServer As String = Current.Request("SERVER_NAME").ToLower

      Select Case strServer
         Case "localhost", "dotnet2", "sites", "dotnet35"
            strMailHost = "mail.flyingbridge.net"

      End Select

      Return strMailHost

   End Function

   ''' <summary>
   ''' Sends an email
   ''' </summary>
   ''' <param name="objMessage">An object of type MailMessage</param>
   ''' <remarks></remarks>
   Public Shared Sub SendEmail(ByVal objMessage As MailMessage)

      Dim smtp As New SmtpClient(GetMailServer)

      smtp.Send(objMessage)

   End Sub

   ''' <summary>
   ''' Sends an email asynchronously
   ''' </summary>
   ''' <param name="objMessage">An object of type MailMessage</param>
   ''' <remarks></remarks>
   Public Shared Sub SendAsyncEmail(ByVal objMessage As MailMessage)

      Dim smtp As New SmtpClient(GetMailServer)

      AddHandler smtp.SendCompleted, AddressOf SendAsyncComplete

      smtp.SendAsync(objMessage, Nothing)

   End Sub

   ''' <summary>
   ''' Completes the asychronous operation
   ''' </summary>
   ''' <param name="sender">An object of type sender</param>
   ''' <param name="e">An object containing event arguments</param>
   ''' <remarks></remarks>
   Private Shared Sub SendAsyncComplete(ByVal sender As Object, ByVal e As ComponentModel.AsyncCompletedEventArgs)

      If e.Error IsNot Nothing Then
         Throw New ApplicationException(e.Error.Message, e.Error.InnerException)

      End If

   End Sub

End Class

Open in new window

lucius_theCommented:
Observe the "Return strMailHost" line. You can change that line to:
Return "mail.yourhost.com"
to make sure that server is always used as an outgoing SMTP. Maybe that's the problem here. The "SendAsyncEmail" method calls the "GetMailServer" routine to get the SMTP server to use.

The server you return ("mail.yourhost.com") should be a server that can send emails without requiring quthentication. This may also be the problem. Some SMTP servers will work without authentication only if you the receipient of the message is in the same domain as the mail server, otherwise you have to authenticate to SMTP. Perhaps you can put a different mail server, some that you have access to from the server this code executes on, that doesn't need authentication and can send emails to anyone.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
HTML5 and CSS3 Fundamentals

Build a website from the ground up by first learning the fundamentals of HTML5 and CSS3, the two popular programming languages used to present content online. HTML deals with fonts, colors, graphics, and hyperlinks, while CSS describes how HTML elements are to be displayed.

chefkeiferAuthor Commented:
i am at a loss...one problem is that i do not have access to other applications on the server. I only have access to the files themselves.

So for instance the site is hosted on their server? In the AsyncMail.vb file can i change all that info to use my server or will thier be some sort of conflict with coding?
lucius_theCommented:
I'm not sure I understand fully... What we are looking at, and commenting, are the .vb code files. Simply changing these files will not make a difference to the web application. These are codes files that you have to compile (in Visual Stubio, or VS for short) after making a change in code. Visual Studio will output one or more DLL files when compile is completed that you need to copy over to the server, in essence, you are replacing the application on the server with your version. If you are not 100% sure that these exact code files were used to compile the application that is currently running on the server, then you can't be sure if changes happened in the mean time.

So, once you are sure you have the latest code files, find a file that ends with .sln. This is the main solution file, you can open it in Visual Studio and it will load all other files a solution uses. Then you can compile the solution from menu Build -> Rebuild, or Rebuild All. If your configuration was "Debug" then your DLL-s will be in bin/Debug folder. If your configuration was "Release", you will find them in bin/release folder. In general, you should use the "Release" configuration when building for production. You can change the active configuration in project properties.

If you never used these tools before, it may be best to ask someone else to build it and make a test publish first, before leaving it in production. In any case, before any experiments, backup your IIS folders so you can revert in case something isn't right. If your app uses a database back-end + if you are not 100% sure that you have the latest sources, don't play with it, because things can easily get out of hand. Try to contact the company/person that produced, or made the last editions to the code, have them do the change and take notes :)
chefkeiferAuthor Commented:
is it possible to just change the extension to a php file and then just use php code for the parsing...aspx is not for me and dont have a lot of time to learn it...I appreciate your help and guidence..
lucius_theCommented:
That is not possible, ASP and PHP are different technologies. Used essentially for the same thing :) But code is not interchangable. You would have to rewrite your application from scratch in PHP.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
ASP

From novice to tech pro — start learning today.