Advertisement

03.31.2008 at 05:13PM PDT, ID: 23284381
[x]
Attachment Details

Creating sendmail using ASP.NET

Asked by legionl2k in Programming for ASP.NET, SendMail Email Server, .NET Framework 2.x

Tags:

HI Experts,

I have a Flash Web Form that sends membership data to my SQL DB via ASP.NET. One of the fields in my Form is "E-Mail".
I would like to be able to send an email to the user confirming their login details, after they have submitted their membership Form.
I will show the code I have at the moment for the membership creation ( which is all working great). I just need to add the SendMail functions to my "process.aspx" page so it can do both
(insert new user into DB and send mail to new user).

thanks.Start Free Trial
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:
135:
136:
137:
138:
139:
140:
141:
142:
143:
144:
145:
146:
147:
148:
149:
150:
151:
152:
153:
154:
155:
156:
157:
158:
159:
160:
161:
162:
<%@ Page Language="VB" ContentType="text/html" ResponseEncoding="iso-8859-1"  %>
<%@ Import Namespace="system.data.sqlclient" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
	Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Load
		Dim username As String = String.Empty
		Dim password As String = String.Empty
		Dim email As String = String.Empty
		Dim fname AS String = String.Empty
		Dim lname AS String = String.Empty
		Dim age As String = String.Empty
		Dim contact As String = String.Empty
		Dim address As String = String.Empty
		Dim suburb AS String = String.Empty
		Dim state As String = String.Empty
		Dim postcode AS String = String.Empty
		Dim country As String = String.Empty
		Dim phone As String = String.Empty
		Dim pregnant AS String = String.Empty
		Dim boys As String = String.Empty
		Dim girls As String = String.Empty
		Dim childage1 As String = String.Empty
		Dim childage2 As String = String.Empty
		Dim childage3 As String = String.Empty
		Dim childage4 As String = String.Empty
		Dim childage5 As String = String.Empty
		Dim feedingmethod AS String = String.Empty
		Dim purchase As String = String.Empty
		Dim hearabout As String = String.Empty
		
		
		If Not IsNothing(Request.Form("username")) Then
			username = Request.Form("username").Trim
		End If
		
		If Not IsNothing(Request.Form("password")) Then
			password = Request.Form("password").Trim
		End If
		
		If Not IsNothing(Request.Form("email")) Then
			email = Request.Form("email").Trim
		End If
		
		If Not IsNothing(Request.Form("age")) Then
			age = Request.Form("age").Trim
		End If
		
		If Not IsNothing(Request.Form("lname")) Then
			lname = Request.Form("lname").Trim
		End If
		
		If Not IsNothing(Request.Form("fname")) Then
			fname = Request.Form("fname").Trim
		End If
		
		If Not IsNothing(Request.Form("contact")) Then
			contact = Request.Form("contact").Trim
		End If
		
		If Not IsNothing(Request.Form("address")) Then
			address = Request.Form("address").Trim
		End If
		
		If Not IsNothing(Request.Form("suburb")) Then
			suburb = Request.Form("suburb").Trim
		End If
		
		If Not IsNothing(Request.Form("state")) Then
			state = Request.Form("state").Trim
		End If
		
		If Not IsNothing(Request.Form("postcode")) Then
			postcode = Request.Form("postcode").Trim
		End If
		
		If Not IsNothing(Request.Form("country")) Then
			country = Request.Form("country").Trim
		End If
		
		If Not IsNothing(Request.Form("phone")) Then
			phone = Request.Form("phone").Trim
		End If
		
		If Not IsNothing(Request.Form("pregnant")) Then
			pregnant = Request.Form("pregnant").Trim
		End If
		
		If Not IsNothing(Request.Form("boys")) Then
			boys = Request.Form("boys").Trim
		End If
		
		If Not IsNothing(Request.Form("girls")) Then
			girls = Request.Form("girls").Trim
		End If
		
		If Not IsNothing(Request.Form("age1")) Then
			childage1 = Request.Form("age1").Trim
		End If
		
		If Not IsNothing(Request.Form("age2")) Then
			childage2 = Request.Form("age2").Trim
		End If
		
		If Not IsNothing(Request.Form("age3")) Then
			childage3 = Request.Form("age3").Trim
		End If
		
		If Not IsNothing(Request.Form("age4")) Then
			childage4 = Request.Form("age4").Trim
		End If
		
		If Not IsNothing(Request.Form("age5")) Then
			childage5 = Request.Form("age5").Trim
		End If
		
		If Not IsNothing(Request.Form("feeding")) Then
			feedingmethod = Request.Form("feeding").Trim
		End If
		
		If Not IsNothing(Request.Form("purchase")) Then
			purchase = Request.Form("purchase").Trim
		End If
		
		If Not IsNothing(Request.Form("hearabout")) Then
			hearabout = Request.Form("hearabout").Trim
		End If
		
		Dim sqlc As New SqlCommand
		sqlc.Connection = New SqlConnection(System.Configuration.ConfigurationSettings.AppSettings("MM_CONNECTION_STRING_conn_abbott_2"))
		sqlc.CommandText = "INSERT INTO abbot3.members_tbl(login_id, password, email, agegroup, firstname, lastname, contactmethod, address, suburb, state, postcode, country, phone, pregnant, boys, girls, childage1, childage2, childage3, childage4, childage5, feedingmethod, purchase, hearabout ) VALUES ('" & username & "', '" & password & "', '" & email & "', '" & age & "', '" & fname & "','" & lname & "', '" & contact & "', '" & address & "', '" & suburb & "', '" & state & "', '" & postcode & "', '" & country & "', '" & phone & "', '" & pregnant & "', '" & boys & "', '" & girls & "', '" & childage1 & "', '" & childage2 & "', '" & childage3 & "', '" & childage4 & "', '" & childage5 & "', '" & feedingmethod & "', '" & purchase & "', '" & hearabout & "')"
		sqlc.CommandType = Data.CommandType.Text
		Dim myWriter As System.IO.TextWriter
			myWriter = Response.Output
		Try
      		 sqlc.Connection.Open()
      		 sqlc.ExecuteNonQuery()
		Catch ex As System.Data.SqlClient.SqlException
      		 If ex.ToString().IndexOf("Cannot insert duplicate key")  > 0 Then 
          		 myWriter.WriteLine("&error=DUPLICATE_INDEX&")
      		 Else
         		  myWriter.WriteLine("&error=GENERAL_ERROR&errorMessage="&ex.ToString()&"&")
      		 End If
      
		Catch ex As Exception
      		  'HERE YOU SHOULD PRINT THE ERROR OUTPUT
       		  myWriter.WriteLine("&error=GENERAL_ERROR&errorMessage="&ex.ToString()&"&")
		Finally
        		 sqlc.Connection.Close()
         		sqlc.Connection.Dispose()
         		sqlc.Dispose()
		End Try
	End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    </form>
</body>
</html>
[+][-]03.31.2008 at 05:50PM PDT, ID: 21250465

View this solution now by starting your 7-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

Zones: Programming for ASP.NET, SendMail Email Server, .NET Framework 2.x
Tags: ASP.NET
Sign Up Now!
Solution Provided By: TSmooth
Participating Experts: 3
Solution Grade: B
 
 
[+][-]04.01.2008 at 12:12PM PDT, ID: 21257085

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

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

 
[+][-]04.01.2008 at 04:02PM PDT, ID: 21258877

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.02.2008 at 05:30AM PDT, ID: 21262287

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.02.2008 at 05:31AM PDT, ID: 21262302

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 01:30AM PDT, ID: 21270525

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 05:54AM PDT, ID: 21272015

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 07:39AM PDT, ID: 21273150

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.03.2008 at 07:42AM PDT, ID: 21273184

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 7-day free trial to view this Expert Comment or ask the Experts your question.

 
[+][-]04.04.2008 at 01:16AM PDT, ID: 21279745

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
[+][-]04.07.2008 at 01:39AM PDT, ID: 21295136

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 7-day free trial to view this Author Comment or ask the Experts your question.

 
 
Loading Advertisement...
20080716-EE-VQP-32 / EE_QW_2_20070628