sending a feedback form to email in asp.net

Please support our ASP.NET advertiser: Intel Parallel Studio Home
Reply

Join Date: May 2008
Posts: 34
Reputation: ricksvoid is an unknown quantity at this point 
Solved Threads: 0
ricksvoid ricksvoid is offline Offline
Light Poster

sending a feedback form to email in asp.net

 
0
  #1
Feb 16th, 2009
I cant seem to find anything wrong with this code. However, I get an error message from my catch block everytime.

  1.  
  2. Imports System
  3. Imports System.net.mail
  4. Imports system.web
  5. Imports System.Web.UI
  6. Imports System.Web.UI.WebControls
  7. Imports System.Web.UI.HtmlControls
  8. Imports System.IO
  9. Partial Class contact2
  10. Inherits System.Web.UI.Page
  11.  
  12. Protected Sub submit_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles submit.Click
  13. Const ToAddress As String = "ricksvoid@yahoo.com"
  14.  
  15. '(1) Create the MailMessage instance
  16. Dim mm As New MailMessage(ToAddress, email.Text)
  17.  
  18. mm.Subject = name.Text
  19. mm.Body = comment.Text
  20. mm.IsBodyHtml = False
  21.  
  22.  
  23. Dim smtp As New SmtpClient
  24. smtp.Host = "smtp.rickpace79.com"
  25. Try
  26.  
  27. smtp.Send(mm)
  28. display2.Text = "message sent"
  29.  
  30. Catch ex As Exception
  31. display2.Text = "An error has accured! </br></br>"
  32.  
  33. End Try
  34. End Sub
  35. End Class

Here is the HTML:

  1. <form id="daForm" runat="Server" action="contact2.aspx">
  2.  
  3. <span class="formText">Please state your name or company.</span><br />
  4.  
  5. <asp:TextBox ID="name" runat="server" Width="280"></asp:TextBox>
  6. <br /><br />
  7.  
  8. <span class="formText">*Enter a contact Email address.</span><br />
  9. <asp:TextBox ID="email" runat="server" Width="280"></asp:TextBox>
  10. <br />
  11.  
  12. <br />
  13.  
  14. <span class="formText">Post a comment or scheduale an interview.</span><br />
  15. <asp:TextBox ID="comment" runat="server" Width="280" Height="100"></asp:TextBox>
  16.  
  17. <br /><br />
  18.  
  19. <asp:Button ID="submit" runat="server" Text="Button" />
  20. <asp:Button ID="clear" runat="server" Text="Button" />
  21. </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
Last edited by peter_budo; Feb 19th, 2009 at 4:15 pm. Reason: Correcting opening tag from [code language="vb.net"] to [code=vb.net]
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 5
Reputation: Jamie Shedley is an unknown quantity at this point 
Solved Threads: 2
Jamie Shedley's Avatar
Jamie Shedley Jamie Shedley is offline Offline
Newbie Poster

Re: sending a feedback form to email in asp.net

 
0
  #2
Feb 19th, 2009
What is the error message you are getting. The error message and stack trace should be enough.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 34
Reputation: ricksvoid is an unknown quantity at this point 
Solved Threads: 0
ricksvoid ricksvoid is offline Offline
Light Poster

Re: sending a feedback form to email in asp.net

 
0
  #3
Feb 19th, 2009
Originally Posted by Jamie Shedley View Post
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.
Reply With Quote Quick reply to this message  
Join Date: Feb 2009
Posts: 5
Reputation: Jamie Shedley is an unknown quantity at this point 
Solved Threads: 2
Jamie Shedley's Avatar
Jamie Shedley Jamie Shedley is offline Offline
Newbie Poster

Re: sending a feedback form to email in asp.net

 
0
  #4
Feb 20th, 2009
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.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC