HOME > ASP > ASP Forum > รบกวนพึ่ๆปรึกษา code send mail หน่อยคะ เช็คค่าวันที่หมดอายุ จาก data base แล้วพบว่ามีคนเดียวที่ครบกำหนด แต่พอ send mail send ออกไปสองครั้ง
[ASP]
รบกวนพึ่ๆปรึกษา code send mail หน่อยคะ เช็คค่าวันที่หมดอายุ จาก data base แล้วพบว่ามีคนเดียวที่ครบกำหนด แต่พอ send mail send ออกไปสองครั้ง
เช็คค่าวันที่หมดอายุ จาก data base แล้วพบว่ามีคนเดียวที่ครบกำหนด แต่พอ send mail send ออกไปสองครั้ง ไม่ทราบว่าเป็นเพราะอะไรคะ ปรึกษาพี่ๆหน่อยคะ ขอบคุณมากคะ
<%
Dim conn,sql,rs
Set conn = Server.Createobject("ADODB.Connection")
conn.Open "driver={microsoft access driver (*.mdb)};DBQ= "&Server.MapPath("dbforeigner.mdb")
sql = "SELECT * FROM tbforeigner where date_alert='"& today &"'"''
Set rs = Server.CreateObject("ADODB.Recordset")
rs.Open sql,conn, 1,3
response.Write(sql)
set rs=conn.Execute(sql)
If rs.EOF Then
response.Write("No Any Data!!!")
Else
main = ""
main1= ""
main2= ""
While Not rs.EOF
'If main = "" & main1="" & main2 = "" Then
main = rs("fempno")
main1 = rs("fempname")
main2 = rs("date_alert")
answ = answ & main & main1 & main2
a=a+1
'End If
rs.MoveNext
Wend
End If
response.Write(answ)
for i=1 to a
Dim ObjSendMail
Set ObjSendMail = CreateObject("CDO.Message")
'This section provides the configuration information for the remote SMTP server.
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'Send the message using the network (SMTP over the network).
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver") ="194.10.10.1"
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = False 'Use SSL for the connection (True or False)
ObjSendMail.Configuration.Fields.Item ("194.10.10.1/cdo/configuration/smtpconnectiontimeout") = 60
' If your server requires outgoing authentication uncomment the lines bleow and use a valid email address and password.
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'basic (clear-text) authentication
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername") ="somemail@yourserver.com"
'ObjSendMail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword") ="yourpassword"
ObjSendMail.Configuration.Fields.Update
'End remote SMTP server configuration section==
ObjSendMail.To = "netna-.-@hotmail.com"
ObjSendMail.Subject = "Mail Alert"
ObjSendMail.From = "saowalukj@lpn.hanabk.th.com"
' we are sending a text email.. simply switch the comments around to send an html email instead
'ObjSendMail.HTMLBody = "this is the body"
ObjSendMail.TextBody = answ
ObjSendMail.Send
If Not ObjSendMail.Send then
Response.write "Send mail Complete!!!"
else
Response.write "Not Don't Send!!!"