Okay,
I'm relatively new with ASP pages and need to know how to send e-mail via my web page. I've looked at the CDO coding and i'm having a hard time understanding why it won't work. it keeps timing out. here is my code:
Protected Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs)
Dim dbusername As String
Dim dbemail As String
Dim foundit As Boolean
Dim Conn As New Data.SqlClient.SqlConnection
Dim Command As New Data.SqlClient.SqlCommand
Dim RS As Data.SqlClient.SqlDataReader
Conn.ConnectionString "some information"
Conn.Open()
Command.CommandType = Data.CommandType.Text
Command.CommandText = "Select * from Security"
Command.Connection = Conn
RS = Command.ExecuteReader
Do While RS.Read
dbusername = Trim(RS("UserName"))
If dbusername = PasswordRecovery1.UserName Then
foundit = True
dbemail = Trim(RS("Email"))
Dim objCDO As Object
objCDO = Server.CreateObject("CDO.Message")
objCDO.From = dbemail
objCDO.To = "myemail@email.com"
objCDO.Subject = "Information from domain.com"
objCDO.Body = "Here's the information you requested"
objCDO.Display()
objCDO = Nothing
Exit Do
End If
Loop
If foundit = False Then
PasswordRecovery1.GeneralFailureText = "Your username was not found!"
End If
Conn.Close()
Conn = Nothing
End Sub
This is all within an asp page. Can someone help me figure out what I'm doing wrong? I want this to work with Outlook since everyone here has it. Thanks!
I'm relatively new with ASP pages and need to know how to send e-mail via my web page. I've looked at the CDO coding and i'm having a hard time understanding why it won't work. it keeps timing out. here is my code:
Protected Sub PasswordRecovery1_SendingMail(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.MailMessageEventArgs)
Dim dbusername As String
Dim dbemail As String
Dim foundit As Boolean
Dim Conn As New Data.SqlClient.SqlConnection
Dim Command As New Data.SqlClient.SqlCommand
Dim RS As Data.SqlClient.SqlDataReader
Conn.ConnectionString "some information"
Conn.Open()
Command.CommandType = Data.CommandType.Text
Command.CommandText = "Select * from Security"
Command.Connection = Conn
RS = Command.ExecuteReader
Do While RS.Read
dbusername = Trim(RS("UserName"))
If dbusername = PasswordRecovery1.UserName Then
foundit = True
dbemail = Trim(RS("Email"))
Dim objCDO As Object
objCDO = Server.CreateObject("CDO.Message")
objCDO.From = dbemail
objCDO.To = "myemail@email.com"
objCDO.Subject = "Information from domain.com"
objCDO.Body = "Here's the information you requested"
objCDO.Display()
objCDO = Nothing
Exit Do
End If
Loop
If foundit = False Then
PasswordRecovery1.GeneralFailureText = "Your username was not found!"
End If
Conn.Close()
Conn = Nothing
End Sub
This is all within an asp page. Can someone help me figure out what I'm doing wrong? I want this to work with Outlook since everyone here has it. Thanks!