mpjbell
Posts: 2
|
| Posted: 05/23/2007, 6:24 AM |
|
I need to have users passwords emailed to them.
I have a form that submits their email address to another page where the query is done.
When the results page loads I want to send an email with the password. I know the query works because I have set the hidden text boxes to be visible. I can do this with PHP but I need to use CDO..messaging and asp because I using an external SMTP server. If I hard code all fields To, From, Subject, Bodytext the email will get sent. But I need to insert the hidden fileds I have retrived from the query. The code below is loading on the before show. Can some one help?
Thanks Mark
CCS 2.3.2.26
ASP
'Custom Code @34-73254650
' -------------------------
'Send Email @34-938401A4
set objEmail = CreateObject("CDO.Message")
objEmail.From = "admin@localhost"
objEmail.To = "User@someplace.com"
objEmail.Subject = "TEST"
objEmail.Body = "TEST"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "10.25.3.115"
objEmail.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
objEmail.Configuration.Fields.Update
objEmail.Send
'End Send Email' -------------------------
'End Custom Code
|
 |
 |
S_A
Posts: 29
|
| Posted: 05/25/2007, 10:38 PM |
|
Hi Mark,
The code you have looks good - all your missing is the value from the actual password field, right?
If I understand correctly, here is some code that I use, but this is with MS Access - not sure what database you're using.
Anyway, harvest what you need from this - I hope it helps.
Regards,
Scott.
'storing the value of email field from form in eid variable
eid=trim(request.form("email"))
if eid="" then
response.redirect "fp.asp"
end if
Set cnnLogin = Server.CreateObject("ADODB.Connection")
cnnLogin.Open("DRIVER={Microsoft Access Driver (*.mdb)};" _
& "DBQ=" & Server.MapPath("../crm/crm.mdb"))
sql="Select * from tbl_fca_users where Email= '"& eid &"' "
Set rstLogin = cnnLogin.Execute(sql)
if not rstLogin.eof then
bool=true
while not rstLogin.eof
user_password=rstLogin("pass")
user_login=rstLogin("username")
rstLogin.movenext
wend
'sending password via CDO
Dim objCDO, txtmessage
Set objCDO = Server.CreateObject("CDO.Message")
objCDO.To = eid
objCDO.From = "admin@my.com"
objCDO.Bcc = "me@my.com"
'now build message body
txtMessage = "Your UserName:"
txtMessage = txtMessage & " " & user_login & CHR(10)
txtMessage = txtMessage & "Your Password:"
txtMessage = txtMessage & " " & user_password & CHR(10)
txtMessage = txtMessage & CHR(10)
objCDO.Subject = "Your password!"
objCDO.TextBody = txtMessage
objCDO.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
'IP of SMTP server
objCDO.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="10.1.1.1"
'Server port
objCDO.Configuration.Fields.Item _
("http://schemas.microsoft.com/cdo/configuration/smtpserverport") =25
objCDO.Configuration.Fields.Update
objCDO.Send
Set objCDO = Nothing
'record exists
Response.write"Your username and password has been sent to your email address, please check your email in a few moments"
'if the record does not exist do this:-
else
bool=false
Response.write"Sorry your email does not exist or check your email address"
end if
|
 |
 |
|