stevemarsh99
Technical User
Hey guys,
I have this page that is supposed to email someone based on a date that sits in a database. The code looks fine but when I run the page it ALWAYS comes back with the 'else' part of the if statement.....ARRRRRRHGGGHH! Any ideas?
(also taking for granted we could fix it, do you think the date would work if the hard coded date that I have used in the example would be replaced with asp code to dynamically display date date in a databse?)
*******************************************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ealert.asp" -->
<%
Dim rs_ealert
Dim rs_ealert_numRows
Set rs_ealert = Server.CreateObject("ADODB.Recordset")
rs_ealert.ActiveConnection = MM_ealert_STRING
rs_ealert.Source = "SELECT * FROM tbl_ealert"
rs_ealert.CursorType = 0
rs_ealert.CursorLocation = 2
rs_ealert.LockType = 1
rs_ealert.Open()
rs_ealert_numRows = 0
%>
<% if 30/11/2005 = dateadd("d", date(), -1) then %>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "WORKING!!"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% else %>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "Its the else of the 'if' statement"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% end if %>
<% MM_EditAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_EditAction = MM_EditAction & "?" & Request.QueryString
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>KHL Digital Magazine eAlerts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
<link href="css/Main_page.css" rel="stylesheet" type="text/css">
</head>
<body>
</body>
</html>
<%
rs_ealert.Close()
Set rs_ealert = Nothing
%>
*******************************************************
I have this page that is supposed to email someone based on a date that sits in a database. The code looks fine but when I run the page it ALWAYS comes back with the 'else' part of the if statement.....ARRRRRRHGGGHH! Any ideas?
(also taking for granted we could fix it, do you think the date would work if the hard coded date that I have used in the example would be replaced with asp code to dynamically display date date in a databse?)
*******************************************************
<%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%>
<!--#include file="Connections/ealert.asp" -->
<%
Dim rs_ealert
Dim rs_ealert_numRows
Set rs_ealert = Server.CreateObject("ADODB.Recordset")
rs_ealert.ActiveConnection = MM_ealert_STRING
rs_ealert.Source = "SELECT * FROM tbl_ealert"
rs_ealert.CursorType = 0
rs_ealert.CursorLocation = 2
rs_ealert.LockType = 1
rs_ealert.Open()
rs_ealert_numRows = 0
%>
<% if 30/11/2005 = dateadd("d", date(), -1) then %>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "WORKING!!"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% else %>
<%
FormFields = "to~body~subject"
If FormFields <> "" Then
arrFormFields = split(FormFields,"~")
End If
Set objCDO = Server.CreateObject("CDONTS.NewMail")
objCDO.From = "Circulation@eAlert.com"
objCDO.To = "marsh@khl.com"
objCDO.Cc = ""
objCDO.Bcc = ""
objCDO.Subject = "Its the else of the 'if' statement"
BodyString = Replace("Extra Hard coded MAIN BODY text","~",chr(13) & chr(10) )& chr(13)
If FormFields <> "" Then
For Each item In arrFormFields
BodyString = BodyString & item & ": " & Request.Form(item) & chr(13)
Next
End If
objCDO.Body = BodyString
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send
Set objCDO = Nothing
RedirectURL = ""
If RedirectURL <> "" then
If Request.QueryString <> "" Then
response.redirect(RedirectURL & "?" & Request.QueryString)
else
response.redirect(RedirectURL)
end If
end if %>
<% end if %>
<% MM_EditAction = CStr(Request("URL"))
If (Request.QueryString <> "") Then
MM_EditAction = MM_EditAction & "?" & Request.QueryString
End If
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "<html>
<head>
<title>KHL Digital Magazine eAlerts</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
-->
</style>
<link href="css/Main_page.css" rel="stylesheet" type="text/css">
</head>
<body>
</body>
</html>
<%
rs_ealert.Close()
Set rs_ealert = Nothing
%>
*******************************************************