Guys,
I have my site working so that when someone enters there ID and hits Login a random 10 char password is generated and its stored with their id in the DB. I also have email from a page StdMail.aspx working but i have the adress of the recipient hard coded in. What Im trying to do is pass the UserID from Login.aspx to StdMail.aspx, Open a connection to the DB, retrieve the Email Address of the User and then email them their new password.
My Code looks like:
<code>
<%@ Page Language ="VB" Debug="True" %>
<%@ Import Namespace="System.Web.Mail" %>
<%@ import Namespace="System.Data" %>
<%@ import Namespace="System.Data.OleDb" %>
<html>
<body>
<script runat = server>
Dim UserID As Integer
UserID = Request.Querystring("txtUserID")
Response.Write(UserID)
Dim aConnection As OleDbConnection = New OleDbConnection
Dim aConnectionString As String
Dim aQuery As String
Dim UserEmail As String
aConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=C:\DB\records.mdb"
aConnection.ConnectionString = aConnectionString
Dim aCommand As OleDbCommand = New OleDbCommand
aConnection.Open()
aQuery = "Select EmailName From Students Where UserID = "& UserID &""
aCommand.Connection = aConnection
aCommand = New OleDbCommand(aQuery, aConnection)
aCommand.ExecuteNonQuery()
</script>
<%
'Send an email address with product information
Dim BodyFormat As String = MailFormat.Html
Dim EmailTo As String = someone@somewhere.com
Dim EmailFrom As String = "CSIS@hotmail.com"
Dim EmailBody As String
Dim EmailSubject As String = "Password For Login"
EmailBody = "Just a Test Email!!!"
'Send the message
SmtpMail.smtpserver = "gabriel.ul.ie"
SmtpMail.Send(EmailFrom, EmailTo, EmailSubject, EmailBody)
'Display notification of mail being sent
Response.Write(UserID)
Response.Write("<font color=red><b>Your Password Has been sent to you! Thank you!</b></font>")
%>
</body>
</html>
</code>
I dont know what to put into EMailTo in order to reference it to the EMailName from the DB. Anyone shed any light on this???