您的位置:首页 > 家用电器 > 音响 > 写数据库+发序列号到邮件

写数据库+发序列号到邮件

luyued 发布于 2011-04-15 11:54   浏览 N 次  

'写入数据库,生成序列号。

code = trim(roundStr(10, 1))

Set objConn = Server.CreateObject("ADODB.Connection")
objConn.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" &_
"Data Source=" & Server.MapPath("\mbti_step2\ajaxrandcode_volvo\db.mdb")
objConn.Open
sql = "select * from checkcode where code = '" & code & "'"
set rs = Server.CreateObject("adodb.recordset")
rs.open sql, conn, 1, 3

if rs.eof then

rs.addnew()

rs("code") = code
rs("email")=buyer_email
rs("riqi")=date()
rs.update()
end if

rs.close()
set rs = nothing


'==================================================
'获取随机字符
function roundStr(l, n)
dim i, j
dim t, s
dim strLen
dim strTemp

strTemp = "0123456789ABCDEFGHIJKLMNOPQRSTOPWXYZ"

for i = 1 to n
for j = 1 to l
randomize()

strLen = Len(strTemp)
t = round((rnd * (strLen - 1)) + 1)
s = s & mid(strTemp, t, 1)
next
next

roundStr = s
End Function

'发送对于序列号到对应邮件。



MailTo = buyer_email

code=code

on error resume next
Server.ScriptTimeout=60000
GB_ip = Request.ServerVariables("REMOTE_ADDR")
email=mailto

Topic = "MBTI测试序列号"

Set m_fso = Server.CreateObject("Scripting.FileSystemObject") '///打开文件
filepath=server.mappath("sendmailmb.htm")
Set m_tf = m_fso.OpenTextFile(filepath, 1)
MailBody = m_tf.ReadAll
Set m_Fso = Nothing
MailBody=replace(MailBody,"code",code)

SendJmail Email,Topic,MailBody,GB_ip

图文资讯
广告赞助商