I cant seem to find anything wrong with this code. However, I get an error message from my catch block everytime.

Imports System
Imports System.net.mail
Imports system.web
Imports System.Web.UI
Imports System.Web.UI.WebControls
Imports System.Web.UI.HtmlControls
Imports System.IO
Partial Class contact2
    Inherits System.Web.UI.Page

    Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
        Const ToAddress As String = "ricksvoid@yahoo.com"

        '(1) Create the MailMessage instance
        Dim mm As New MailMessage(ToAddress, email.Text)

        mm.Subject = name.Text
        mm.Body = comment.Text
        mm.IsBodyHtml = False


        Dim smtp As New SmtpClient
        smtp.Host = "smtp.rickpace79.com"
        Try

            smtp.Send(mm)
            display2.Text = "message sent"

        Catch ex As Exception
            display2.Text = "An error has accured! </br></br>"

        End Try
    End Sub
End Class

Here is the HTML:

<form id="daForm" runat="Server" action="contact2.aspx">
						
							<span class="formText">Please state your name or company.</span><br />
                                
                        <asp:TextBox ID="name" runat="server" Width="280"></asp:TextBox>
							<br /><br />
							
							<span class="formText">*Enter a contact Email address.</span><br />
                        <asp:TextBox ID="email" runat="server" Width="280"></asp:TextBox>
                           <br />
                                
							<br />
							
							<span class="formText">Post a comment or scheduale an interview.</span><br />
                        <asp:TextBox ID="comment" runat="server" Width="280" Height="100"></asp:TextBox>
                               
							<br /><br />
														
                        <asp:Button ID="submit" runat="server" Text="Button" />
                        <asp:Button ID="clear" runat="server" Text="Button" />
                            </form>

Could there be a problem with the form tag? Maybe im missing a peice of information in the action attribute?

Please help,
Rick Pace

What is the error message you are getting. The error message and stack trace should be enough.

What is the error message you are getting. The error message and stack trace should be enough.

error = System.

the stack trace leads me to line 26 smtp.send.

Im begining to think its my hosting company aplus.net. Ive learned the hard way that its not worth it to save a few dollars on hosting.

It may be a permissions issue. Under the SMTP variable i believe that there is a username and password property. Try setting these values with the username and password for the email account that will be receiving the email. I dont know if this will work for this scenario but i have had a similar problem before and it was down to permissions. If this still doesn't work try impersonating a user within the web.config file.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.