PDA

View Full Version : Novice requires help sending email with ASP!



neiljackson
01-10-2007, 03:25 PM
Hi,
This is a long posting, please bear with me!
I've been integrating some chat software into a website. It all runs off asp scripts and I'm getting my head round most of it.
But the one section I can't get to work is where users can have their usernames and passwords emailed to them. It tells me if I type in an address that hasn't been registered and if i enter in a correct one it takes me back to the log in screen with a message saying my password has been emailed. But nothing arrives.

The script supplied is as follows:
<!--#include file="config.asp" -->
<%
Dim varEmail : varEmail = request("txtEmail")

'get the persons details out of the database
varSQL = "SELECT USERNAME, PASSWORD, EMAIL FROM USERS WHERE EMAIL='" & varEMail & "';"
Set rs=Server.CreateObject("ADODB.recordset")
rs.Open varSQL, strConnString, 0, 1
If rs.EOF Then
'no email in the database
Response.Redirect("register_passremind.asp?Error=noemail")
Else
Dim varUsername : varUsername = rs("USERNAME")
Dim varPassword : varPassword = rs("PASSWORD")
varEmail = rs("EMAIL")
'send an email to the user with their username and password
Dim objMail
Set objMail = server.createobject("cdonts.newmail")
objMail.to = varEmail
objMail.from = application("ChatEmail")
objMail.body = application("lang_passsend_1") & varUsername & vbCrLf & vbCrLf & application("lang_passsend_2") & application("lang_passsend_3") & vbCrLf & vbCrLf & application("lang_passsend_4") & varUsername & vbCrLf & application("lang_passsend_5") & varPassword
objMail.subject = application("lang_passsend_6")
objMail.send

Set objMail = nothing
rs.Close
Set rs = Nothing
Response.Redirect("home.asp?Error=passsent&Email=" & varEmail)
End If
rs.Close
Set rs = Nothing
%>


My hosting company does not support CDONTS so I have to use CDOSYS instead. They have supplied the following sample script but haven't a clue how to integrate it into the original one. Can anyone help a very frustrated novice!

Dim MailMessage As New MailMessage
With MailMessage
.From = "email address"
.To = txtSendTo.Text
.Subject = "Subject Line Here"
.Body = txtMessageBody.Text

.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "intmail.atlas.pipex.net"
.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2

.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = "Email user"
.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "email password"
End With

Try
SmtpMail.Send(MailMessage)

Catch ex As Exception
End Try