[x]
Posted via EE Mobile

Search, ask, and monitor your questions on the go with EE Mobile. Visit Experts Exchange from your mobile device and never be out of touch again.

Question
[x]
Attachment Details
[x]
The Solution Rating System

With so many solutions, how can you tell which solutions are most likely to help you and which ones are not? To provide you with a tool to use, we rate our solutions based on various elements that most accurately determine if a solution is a quality solution. To explain what factors affect the solution rating, here are the elements we take into consideration when formulating our solution rating.

  • The Grade of the Solution
  • The Zone Rank of the Expert Providing the Solution
  • The Number of Author and Expert Comments
  • The Number of Experts Contributing
  • The Feedback of the Community

Your Input Matters
Because of the way the system is set up, the most important variable in this equation is you. As a member of Experts Exchange, you are able to cast your vote on the quality of the solutions in regard to how complete, accurate, helpful and easy to understand each solution is. When you provide your feedback, each rating is adjusted accordingly. So, if you see a solution that has a poor rating that you think is a good solution, let us know by rating it. As you do, the rating will be adjusted and will become more accurate for other members of our site.

If you have any suggestions that you would like to make for our rating system, please ask a question in the Suggestions Zone of Community Support.

Thank you!

9.4

Email a form

Asked by Bertrendy in Programming for ASP.NET

Tags: VB.net

Uncle! I am out of time and lost on what I am doing wrong in many places. I have been pulling pieces of code from everywhere I can find it, and I can't get this email form to work.


Goal of this page: Take the contents from the form and send them in the body of the email.

What is working: The email features works perfect, using godaddy smtp (hosted at godaddy) and when preset variables are set.  

What is not working/what I cant figure out:
      I need to get the contents of the form into the email function
      I need to get all the variables into the email body. (see the code, its partially commented out)
      I need to post back a message to the user that their message has gone through successfully or if it has failed.

Any help would be greatly appreciated.  I am an advanced-novice at vb.net so please be as clear as possible. Thanks!!!!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:
51:
52:
53:
54:
55:
56:
57:
58:
59:
60:
61:
62:
63:
64:
65:
66:
67:
68:
69:
70:
71:
72:
73:
74:
75:
76:
77:
78:
79:
80:
81:
82:
83:
84:
85:
86:
87:
88:
89:
90:
91:
92:
93:
94:
95:
96:
97:
98:
99:
100:
101:
102:
103:
104:
105:
106:
107:
108:
109:
110:
111:
112:
113:
114:
115:
116:
117:
118:
119:
120:
121:
122:
123:
124:
125:
126:
127:
128:
129:
130:
131:
132:
133:
134:
<script runat="server">
 
Sub TiggerEmail(sender as Object, e as EventArgs) Handles MyBase.Load
	SendMail (Request.Form("fname") + Request.Form("contacttime") + Request.Form("email") + Request.Form("phone"))
	end sub
 
 
 
'QUESTION 1 - HOW TO GET MY FORM VALUES INTO THIS SUB 
Private Sub SendMail(ByVal fname As String, ByVal phone As String, ByVal email As String, ByVal contacttime As String)
 
        'Set the HostName
        Dim host As String = "SMTP SERVER"
        Dim ToEmail As String = "joe@joe.com"
		Dim FromEmail As String = "bill@bill.com"
 
        Dim Subject As String = "Contact submission"
		
			'QUESTION 2 - HOW DO I GET THSE VALUES INTO THE BODY?
		Dim body as string = "Name: " '& fname & "   Phone: " & phone & "    Email: " & email & "     Contact Time: " & contacttime
 
		Dim Result As String = ""
 
 
        Dim Email As New System.Net.Mail.MailMessage(FromEmail, ToEmail)
		
 
		Dim mailClient As New System.Net.Mail.SmtpClient(host)
		mailClient.Host = host
		'mailClient.EnableSsl = True
		
        Email.Subject = Subject
        Email.Body = body
 
        
        'Dim port As Int32 = 465  ' WITH SSL
		Dim port As Int32 = 80	' NO SSL
              
        Dim authenticationInfo As _
          New System.Net.NetworkCredential( _
           "username", _
           "password")
 
        mailClient.UseDefaultCredentials = False
        mailClient.Credentials = authenticationInfo
       
        Try
		  mailClient.Send(Email)
		  Result = "OK"
		  
		  Catch ex As Exception
		  
			Response.Write("Unable to send email, the following error has occurred:" & vbCrLf & vbCrLf & _
		 ex.Message)
		 
		End Try
 
 
        Email.Dispose()
        mailClient = Nothing
		Host = Nothing
        GC.Collect()
 
    End Sub
 
</script>
<BODY>
 
<table width="300px" height="200px">
	<tr>
		<td>        
 
	<!-- QUESTION 3 - How do I post back a message that says their submission went through?  -->
   	<div>
    	<p>Your submission has been sent successfully.</p>
    </div>
    
      <form id="contactform" runat="server">
    
    
    <div>
	    <asp:ValidationSummary
    		ID                  = "Summary"
            runat               = "server"
            DisplayMode         = "BulletList" /></div>
    
    
    
    <div>First Name:
    	<asp:TextBox ID="fname" runat="server"></asp:TextBox></div>
    	<asp:RequiredFieldValidator
        	ID                  = "rfname"
        	runat               = "server"
            ControlToValidate   = "fname"
            ErrorMessage        = "Name Required"
            Display             = "None" />
    <div>Phone: Ex.(222-222-2222 x22)
    <asp:TextBox ID="phone" runat="server"></asp:TextBox></div>
    	<asp:RegularExpressionValidator
    		ID                  = "regPhone"
            runat               = "server"
            ControlToValidate   = "phone"
            Display             = "None"
            ErrorMessage        = "Invalid Phone Number"
            ValidationExpression= "((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}( x\d{0,})?" />
                                
    <div>Email address:
    	<asp:TextBox ID="email" runat="server"></asp:TextBox></div>
        <asp:RegularExpressionValidator
        ID                  = "regEmail"
        runat               = "server"
        ControlToValidate   = "Email"
        Display             = "None"
        ErrorMessage        = "Invalid Email"
        ValidationExpression= "\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*" />
             
    
    <div>
    	<asp:DropDownList ID="contacttime" runat="server">
        <asp:ListItem Value="9am_12pm">9am-12pm</asp:ListItem>
        <asp:ListItem Value="12pm_3pm">12pm-3pm</asp:ListItem>
        <asp:ListItem Value="3pm_6pm">3pm-6pm</asp:ListItem>
        </asp:DropDownList></div>
    </div>
    
    
  		<asp:button id="btnSubmit" runat="server" OnClick="SendMail" Text="Submit" />
  
            </form>
		</td>
  </tr>                         
</table>
  
</BODY>
[+][-]08/15/09 09:44 PM, ID: 25107802Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/09 08:23 AM, ID: 25109247Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/16/09 11:53 AM, ID: 25109925Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/09 11:55 AM, ID: 25109940Expert Comment

At Experts Exchange, members can ask their questions to thousands of technology professionals, also known as Experts. Experts compete and collaborate to answer those questions by leaving comments like this one.

Start your 30-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]08/16/09 01:24 PM, ID: 25110328Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/16/09 09:56 PM, ID: 25111692Accepted Solution

View this solution now by starting your 30-day free trial. Setting up your free trial is quick, easy, and secure. We will return you to this solution, unlocked, when you're done.

About this solution

Zone: Programming for ASP.NET
Tags: VB.net
Sign Up Now!
Solution Provided By: Mortaza_doulaty
Participating Experts: 1
Solution Grade: A
 
[+][-]08/17/09 12:14 PM, ID: 25117423Author Comment

Often, when Experts are collaborating with members who have asked questions, they will request additional information about the problem. Askers respond with an author comment like this one.

Start your 30-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]08/17/09 01:21 PM, ID: 25118000Assisted Solution

Assisted solutions are selected by the member who asked the question as a comment that contributed to their question's solution.

Start your 30-day free trial to view this Assisted Solution or ask the Experts your question.

 
 
Loading Advertisement...
20091111-EE-VQP-89 - Hierarchy / EE_QW_3_20080625