Opret og mail med jmail
jeg har lavet en formular hvor en bruger kan oprette en profil fra en formular og gemmes i access database.Alt dette virker men nu kommer der så et problem for når de opretter en profil skal den lave et "Random password" og sende det til deres email med brugernavn og andre informationer.
Problemet er bare hvordan jeg får det er at virke og håber at nogle her kan give mig den sidste hjælp så det kommer til at virke.
gem info:
<%
username = trim(ChkString(Request.form("username")))
fname = trim(ChkString(Request.form("fname")))
sname = trim(ChkString(Request.form("sname")))
email = trim(ChkString(Request.form("email")))
country = trim(ChkString(Request.form("country")))
city = trim(ChkString(Request.form("city")))
gender = trim(ChkString(Request.form("gender")))
age = trim(ChkString(Request.form("age")))
height = trim(ChkString(Request.form("height")))
weight = trim(ChkString(Request.form("weight")))
childen = trim(ChkString(Request.form("childen")))
drink = trim(ChkString(Request.form("drink")))
beskrivelse = trim(ChkString(Request.form("beskrivelse")))
sogerbeskrivelse = trim(ChkString(Request.form("sogerbeskrivelse")))
' BEGIN - Check if Real Name is valid
If Len(fname)<2 Then
Err_Message=Err_Message&"Real name to short or missing<BR>"&vbCrLf
end if
' END - Check if Real Name is valid
' BEGIN - Check if Real Name is valid
If Len(sname)<2 Then
Err_Message=Err_Message&"Real name to short or missing<BR>"&vbCrLf
end if
' END - Check if Real Name is valid
' #### BEGIN ## Generate random password ####
Randomize
Str_Password=""
For x=1 to 10
Password=Password&Chr(Int(26*rnd)+65)
Next
Password=Lcase(Password)
' #### END ## Generate random password ####
' #### BEGIN ## If no errors, create account ####
If Err_Message="" Then
Function ChkString(str)
str = replace(str, "<", "<", 1, -1, 1)
str = replace(str, ">", ">", 1, -1, 1)
ChkString = str
End Function
ConnString = "DRIVER={Microsoft Access Driver (*.mdb)};DBQ=" & Server.MapPath("admin/member.mdb")
set my_conn= Server.CreateObject("ADODB.Connection")
my_Conn.Open ConnString
set rscheck = my_conn.Execute ("Select email from member where email='" & email & "'")
if rscheck.eof then
been_here_before="No"
end if
RScheck.close
set rs = server.CreateObject("adodb.recordset")
if been_here_before="No" then
sql ="select * from member"
RS.open Sql,my_conn,1,3
RS.AddNew
RS("username")=username
RS("fname")=fname
RS("sname")=sname
RS("email")=email
RS("country")=country
RS("city")=city
RS("gender")=gender
RS("age")=age
RS("height")=height
RS("weight")=weight
RS("childen")=childen
RS("drink")=drink
RS("beskrivelse")=beskrivelse
RS("sogerbeskrivelse")=sogerbeskrivelse
RS("password")= password
RS("memberdate")= date()
RS.update
end if
Session("Mail_User_Username")=Username
end if
Response.Redirect "Send_AccountInfo.asp"
' #### END ## If no errors, create account ####
rs.close
my_conn.Close
set my_conn = nothing
set rs = nothing
%>
Send info:
<%
username = session("Mail_User_Username")
Str_Temp=Replace(Session("Mail_User_Username")&"","'","''")
Str_Temp=Replace(Str_Temp,"""","""""")
Set Conn = Server.CreateObject("ADODB.Connection")
DSN = "DRIVER={Microsoft Access Driver (*.mdb)}; "
DSN = DSN & "DBQ=" & Server.MapPath("admin/member.mdb")
Conn.Open DSN
strSQL = "Select ID, username, fname, sname, password, email From member Where username like = '"&Str_Temp&"'"
Set rs = Conn.Execute(strSQL)
Do
strID = rs("ID")
strfnavn = rs("fnavn")
strsname = rs("sname")
strpassword = rs("password")
stremail = rs("email")
' #### BEGIN ## Send e-mail to user, using JMail component (http://tech.dimac.net/) ####
Name = "Real Thai Dating"
SenderEmail = "thai@thai-estate.info"
Subject = "Welcome to real dating asia"
Recipient = Str_email
' BEGIN - Generate message
Str_Message=""
Str_Message=Str_Message&"Welcome to Internal Message System, " & Str_fname & Str_sname & vbCrLf & vbCrLf
Str_Message=Str_Message&"You have now created an account at Internal Message System, and must click on the link just below to activate the account, before you can use the username & password for login:" & vbCrLf
Str_Message=Str_Message&" http://www.pizzacentral.dk/internalmailsystem/mail_activate_account.asp?accountid=" & Str_ID & vbCrLf & vbCrLf
Str_Message=Str_Message&"When you have got the message that the account has been activated, use your username and password." & vbCrLF & vbCrLF
Str_Message=Str_Message&"Here is your account details:" & vbCrLf
Str_Message=Str_Message&" Username: " & Str_username & vbCrLf
Str_Message=Str_Message&" Password: " & Str_password & vbCrLf & vbCrLf
Str_Message=Str_Message&"Use your username and password to login. Have fun! :)" & vbCrLf & vbCrLf
Str_Message=Str_Message&"Regards" & vbCrLf
Str_Message=Str_Message&"I.M.S. Bot" & vbCrLf
Str_Message=Str_Message&"Internal Message System v1.00" & vbCrLf
Str_Message=Str_Message&"http://www.thai-estate.info" & vbCrLf& vbCrLf
Str_Message=Str_Message&"P.S. If your have received this e-mail and haven't created an account at Internal Message System (http://www.thai-estate.info), we are sorry and would like if you could please send an e-mail, so it can be cancelled." & vbCrLf
' END - Generate message
Set JMail = Server.CreateObject("JMail.SMTPMail")
' Enter your own SMTP-server here
JMail.ServerAddress = "post1.wendt-net.dk"
JMail.Sender = SenderEmail
JMail.Subject = Subject
JMail.AddRecipient Recipient
JMail.Body = Str_Message
JMail.Priority = 3
JMail.AddHeader "Originating-IP", Request.ServerVariables("REMOTE_ADDR")
JMail.Execute
' #### END ## Account Send e-mail to user, using JMail component (http://tech.dimac.net/) ####
Response.Redirect "login.asp"
Loop While Not rs.EOF
' Luk databaseforbindelse
Conn.Close
Set Conn = Nothing
%>