Get ready for BLACK FRIDAY shopping starting in

Forums

ASP

This topic is locked

create ASP report and have it emailed automaticall

Posted 20 Oct 2004 02:26:12
1
has voted
20 Oct 2004 02:26:12 colin hart posted:
I have a ASP page that I created that shows yesterdays activity for a database which works great when a user logs into the site and opens that page. I want to have that page emailed to all my users, not a link but take the page and have an html email sent to my users (stored in a SQL database) everynight. We have over 1000 users so it will be a big batch of emails.

I am using Exchange 5.5 for email
Webserver is sql2000 and I mostly program in ASP

what suggestions do you have for me?

Replies

Replied 20 Oct 2004 14:18:06
20 Oct 2004 14:18:06 Rene Bandsma replied:
Think this is not possible. ASP is an scripting language to display text in a browser or process some functions to the server while loading the page or when a user interacts with the ASP script.

If you want to mass-mail all your addressees at once at a certain time every day you should do some things manually (like clicking on OK or load a page). With the Smart Mail Processor you can easily add your wanted fuctionality to your webpage.
Replied 20 Oct 2004 18:06:06
20 Oct 2004 18:06:06 colin hart replied:
what is the Smart Mail Processor?
Replied 20 Oct 2004 20:24:01
20 Oct 2004 20:24:01 Rene Bandsma replied:
<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
what is the Smart Mail Processor?
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
A great extension from the developers of DMXZone: www.dmxzone.com/ShowDetail.asp?NewsId=5578
Replied 25 Oct 2004 17:01:45
25 Oct 2004 17:01:45 Lee Diggins replied:
Hi Colin

You can do this a number of different ways, all dependent on your configuration. One of the simplest ways would be to write a VBS file (just like ASP/VBScript) and create a task in Windows Scheduler to run every night.

Have you coded for this kind of thing before?

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 25 Oct 2004 17:36:45
25 Oct 2004 17:36:45 colin hart replied:
hey digga
thanks for the response. I got a simple one of these working using that Mail Processor but this next one is too difficult for it to handle.

here is my latest project
I am building a site for a real estate company and they want the ability for visitors to record their search criteria and and have the server run that criteria every night and email them if there are listings.
Currently now I have I form online where they insert the search criteria (Price Range High, Price range Low, bed, bath, square footage, City and House Type) and their email address into a table named SavedSearchCriteria. I got that part working great. Now I need to have it. Then I have a table named ResData that is the database of available houses that I need to have it search. I can get it to do one search but I can't get it to repeat for each person and email them the results.

what do you suggest?
Replied 25 Oct 2004 17:47:11
25 Oct 2004 17:47:11 Lee Diggins replied:
Hi Colin

Post the code you have so far, probably just need another loop.

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 25 Oct 2004 18:03:19
25 Oct 2004 18:03:19 colin hart replied:
thanks again
here is the code that writes the results to the page. I am lost on the email part too as I can only make it work once, everytime I try to do a repart it does

here he the code
&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;!--#include file="../Connections/RemaxIntranetMLS.asp" --&gt;
&lt;%
Dim rsSearchCriteria__MMColParam
rsSearchCriteria__MMColParam = "1"
If (Request("MM_EmptyValue" &lt;&gt; "" Then
rsSearchCriteria__MMColParam = Request("MM_EmptyValue"
End If
%&gt;
&lt;%
Dim rsSearchCriteria
Dim rsSearchCriteria_numRows

Set rsSearchCriteria = Server.CreateObject("ADODB.Recordset"
rsSearchCriteria.ActiveConnection = MM_RemaxIntranetMLS_STRING
rsSearchCriteria.Source = "SELECT ID, UserID, ImputDate, City, Type, PriceLow, PriceHigh, Bed, Bath, Sqft, name, status, email, fullName FROM dbo.SavedSearchCriteria WHERE status = '" + Replace(rsSearchCriteria__MMColParam, "'", "''" + "' ORDER BY ID ASC"
rsSearchCriteria.CursorType = 0
rsSearchCriteria.CursorLocation = 2
rsSearchCriteria.LockType = 1
rsSearchCriteria.Open()

rsSearchCriteria_numRows = 0
%&gt;
&lt;%
Dim rsPropSearch__MMColParam
rsPropSearch__MMColParam = "%"
If (rsSearchCriteria("City" &lt;&gt; "" Then
rsPropSearch__MMColParam = rsSearchCriteria("City"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam1
rsPropSearch__MMColParam1 = "1"
If (rsSearchCriteria("PriceLow" &lt;&gt; "" Then
rsPropSearch__MMColParam1 = rsSearchCriteria("PriceLow"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam2
rsPropSearch__MMColParam2 = "1"
If (rsSearchCriteria("PriceHigh" &lt;&gt; "" Then
rsPropSearch__MMColParam2 = rsSearchCriteria("PriceHigh"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam3
rsPropSearch__MMColParam3 = "%"
If (rsSearchCriteria("Type" &lt;&gt; "" Then
rsPropSearch__MMColParam3 = rsSearchCriteria("Type"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam4
rsPropSearch__MMColParam4 = "1"
If (rsSearchCriteria("Bed" &lt;&gt; "" Then
rsPropSearch__MMColParam4 = rsSearchCriteria("Bed"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam5
rsPropSearch__MMColParam5 = "1"
If (rsSearchCriteria("Bath" &lt;&gt; "" Then
rsPropSearch__MMColParam5 = rsSearchCriteria("Bath"
End If
%&gt;
&lt;%
Dim rsPropSearch
Dim rsPropSearch_numRows

Set rsPropSearch = Server.CreateObject("ADODB.Recordset"
rsPropSearch.ActiveConnection = MM_RemaxIntranetMLS_STRING
rsPropSearch.Source = "SELECT dbo.exp_Member.FullName, dbo.ResData.AgentList, dbo.ResData.MLSNum, dbo.ResData.ListPrice, dbo.ResData.Beds, dbo.ResData.BathsTotal, dbo.ResData.SqFtTotal, dbo.ResData.YearBuilt, dbo.ResData.StreetNum, dbo.ResData.StreetName, dbo.ResData.Remarks, dbo.ResData.City, dbo.ResData.PropType FROM dbo.exp_Member INNER JOIN dbo.ResData ON dbo.exp_Member.PubID = dbo.ResData.AgentList WHERE (dbo.ResData.ListPrice &gt;= '" + Replace(rsPropSearch__MMColParam1, "'", "''" + "' AND dbo.ResData.ListPrice &lt;= '" + Replace(rsPropSearch__MMColParam2, "'", "''" + "') AND dbo.ResData.City = '" + Replace(rsPropSearch__MMColParam, "'", "''" + "' AND (dbo.ResData.ListStatus = 'ACT' OR dbo.ResData.ListStatus = 'BACK') AND dbo.ResData.PropSubType = '" + Replace(rsPropSearch__MMColParam3, "'", "''" + "' AND dbo.ResData.Beds &gt;= '" + Replace(rsPropSearch__MMColParam4, "'", "''" + "' AND dbo.ResData.BathsTotal &gt;= '" + Replace(rsPropSearch__MMColParam5, "'", "''" + "' AND ListDate &gt;=GETDATE()-2 ORDER BY ListPrice DESC"
rsPropSearch.CursorType = 3
rsPropSearch.CursorLocation = 3
rsPropSearch.LockType = 1
rsPropSearch.Open()

rsPropSearch_numRows = 0
%&gt;
&lt;%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsPropSearch_numRows = rsPropSearch_numRows + Repeat1__numRows
%&gt;
&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;Dear &lt;%=(rsSearchCriteria.Fields.Item("fullName".Value)%&gt;&lt;/p&gt;
&lt;table width="100%" border="0" cellspacing="1" cellpadding="1"&gt;
&lt;tr&gt;
&lt;td width="27%"&gt;Address&lt;/td&gt;
&lt;td width="16%"&gt;City&lt;/td&gt;
&lt;td width="14%"&gt;Beds&lt;/td&gt;
&lt;td width="30%"&gt;baths&lt;/td&gt;
&lt;td width="13%"&gt;Sq Ft &lt;/td&gt;
&lt;/tr&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsPropSearch.EOF))
%&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("StreetNum".Value)%&gt;&lt;img src="../spacer.gif" width="1" height="1"&gt;&lt;%=(rsPropSearch.Fields.Item("StreetName".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("City".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("Beds".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("BathsTotal".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("SqFtTotal".Value)%&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsPropSearch.MoveNext()
Wend
%&gt;

&lt;/table&gt;
&lt;p&gt;thanks &lt;/p&gt;
&lt;p&gt;RE/MAX Real Estate &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsSearchCriteria.Close()
Set rsSearchCriteria = Nothing
%&gt;
&lt;%
rsPropSearch.Close()
Set rsPropSearch = Nothing
%&gt;

Replied 25 Oct 2004 18:28:51
25 Oct 2004 18:28:51 Lee Diggins replied:
Can you post your email code too, I thought you got one going?

Digga

Sharing Knowledge Saves Valuable Time!!!
Replied 25 Oct 2004 18:41:21
25 Oct 2004 18:41:21 colin hart replied:
my bad, I gave you the wrong page
&lt;%@LANGUAGE="VBSCRIPT" CODEPAGE="1252"%&gt;
&lt;!--#include file="../Connections/RemaxIntranetMLS.asp" --&gt;
&lt;%
Dim rsSearchCriteria__MMColParam
rsSearchCriteria__MMColParam = "1"
If (Request("MM_EmptyValue" &lt;&gt; "" Then
rsSearchCriteria__MMColParam = Request("MM_EmptyValue"
End If
%&gt;
&lt;%
Dim rsSearchCriteria
Dim rsSearchCriteria_numRows

Set rsSearchCriteria = Server.CreateObject("ADODB.Recordset"
rsSearchCriteria.ActiveConnection = MM_RemaxIntranetMLS_STRING
rsSearchCriteria.Source = "SELECT ID, UserID, ImputDate, City, Type, PriceLow, PriceHigh, Bed, Bath, Sqft, name, status, email, fullName FROM dbo.SavedSearchCriteria WHERE status = '" + Replace(rsSearchCriteria__MMColParam, "'", "''" + "' ORDER BY ID ASC"
rsSearchCriteria.CursorType = 0
rsSearchCriteria.CursorLocation = 2
rsSearchCriteria.LockType = 1
rsSearchCriteria.Open()

rsSearchCriteria_numRows = 0
%&gt;
&lt;%
Dim rsPropSearch__MMColParam
rsPropSearch__MMColParam = "%"
If (rsSearchCriteria("City" &lt;&gt; "" Then
rsPropSearch__MMColParam = rsSearchCriteria("City"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam1
rsPropSearch__MMColParam1 = "1"
If (rsSearchCriteria("PriceLow" &lt;&gt; "" Then
rsPropSearch__MMColParam1 = rsSearchCriteria("PriceLow"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam2
rsPropSearch__MMColParam2 = "1"
If (rsSearchCriteria("PriceHigh" &lt;&gt; "" Then
rsPropSearch__MMColParam2 = rsSearchCriteria("PriceHigh"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam3
rsPropSearch__MMColParam3 = "%"
If (rsSearchCriteria("Type" &lt;&gt; "" Then
rsPropSearch__MMColParam3 = rsSearchCriteria("Type"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam4
rsPropSearch__MMColParam4 = "1"
If (rsSearchCriteria("Bed" &lt;&gt; "" Then
rsPropSearch__MMColParam4 = rsSearchCriteria("Bed"
End If
%&gt;
&lt;%
Dim rsPropSearch__MMColParam5
rsPropSearch__MMColParam5 = "1"
If (rsSearchCriteria("Bath" &lt;&gt; "" Then
rsPropSearch__MMColParam5 = rsSearchCriteria("Bath"
End If
%&gt;
&lt;%
Dim rsPropSearch
Dim rsPropSearch_numRows

Set rsPropSearch = Server.CreateObject("ADODB.Recordset"
rsPropSearch.ActiveConnection = MM_RemaxIntranetMLS_STRING
rsPropSearch.Source = "SELECT dbo.exp_Member.FullName, dbo.ResData.AgentList, dbo.ResData.MLSNum, dbo.ResData.ListPrice, dbo.ResData.Beds, dbo.ResData.BathsTotal, dbo.ResData.SqFtTotal, dbo.ResData.YearBuilt, dbo.ResData.StreetNum, dbo.ResData.StreetName, dbo.ResData.Remarks, dbo.ResData.City, dbo.ResData.PropType FROM dbo.exp_Member INNER JOIN dbo.ResData ON dbo.exp_Member.PubID = dbo.ResData.AgentList WHERE (dbo.ResData.ListPrice &gt;= '" + Replace(rsPropSearch__MMColParam1, "'", "''" + "' AND dbo.ResData.ListPrice &lt;= '" + Replace(rsPropSearch__MMColParam2, "'", "''" + "') AND dbo.ResData.City = '" + Replace(rsPropSearch__MMColParam, "'", "''" + "' AND (dbo.ResData.ListStatus = 'ACT' OR dbo.ResData.ListStatus = 'BACK') AND dbo.ResData.PropSubType = '" + Replace(rsPropSearch__MMColParam3, "'", "''" + "' AND dbo.ResData.Beds &gt;= '" + Replace(rsPropSearch__MMColParam4, "'", "''" + "' AND dbo.ResData.BathsTotal &gt;= '" + Replace(rsPropSearch__MMColParam5, "'", "''" + "' AND ListDate &gt;=GETDATE()-2 ORDER BY ListPrice DESC"
rsPropSearch.CursorType = 3
rsPropSearch.CursorLocation = 3
rsPropSearch.LockType = 1
rsPropSearch.Open()

rsPropSearch_numRows = 0
%&gt;
&lt;%
Dim Repeat1__numRows
Dim Repeat1__index

Repeat1__numRows = -1
Repeat1__index = 0
rsPropSearch_numRows = rsPropSearch_numRows + Repeat1__numRows
%&gt;


&lt;%
'***Insert the ASP mail after the Insert Record
'***insert returns to this page, so the form variables are available
Dim Body
Set Mailer = Server.CreateObject("SMTPsvg.Mailer"
Mailer.FromName = "Colin Hart"
Mailer.FromAddress= " "
Mailer.RemoteHost = "mail.homesoc.com"
Mailer.AddRecipient rsPropSearch.Fields.Item("fullName".Value, rsPropSearch.Fields.Item("email".Value 'MIS dept
Mailer.Subject = "Daily Mathces"
Body = "&lt;p&gt;Dear " & rsSearchCriteria.Fields.Item("fullName".Value & "&lt;/p&gt;" & vbCRLF _
& "&lt;table width=""100%"" border=""0"" cellspacing=""1"" cellpadding=""1""&gt;&lt;tr&gt;&lt;td width=""27%""&gt;Address&lt;/td&gt;&lt;td width=""16%""&gt;City&lt;/td&gt;" & vbCRLF _
& "&lt;td width=""14%""&gt;Beds&lt;/td&gt;&lt;td width=""30%""&gt;baths&lt;/td&gt;&lt;td width=""13%""&gt;Sq Ft &lt;/td&gt;&lt;/tr&gt;" & vbCRLF _
& While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsPropSearch.EOF)) & vbCRLF _
& "&lt;tr&gt;&lt;td&gt;" & rsPropSearch.Fields.Item("StreetNum".Value & "&lt;img src=""../spacer.gif"" width=""1"" height=""1""&gt;" & rsPropSearch.Fields.Item("StreetName".Value & vbCRLF _
& "&lt;/td&gt;&lt;td&gt;" & rsPropSearch.Fields.Item("City".Value & "&lt;/td&gt;&lt;td&gt;" & rsPropSearch.Fields.Item("Beds".Value & "&lt;/td&gt;&lt;td&gt;" & vbCRLF _
& rsPropSearch.Fields.Item("BathsTotal".Value & "&lt;/td&gt;&lt;td&gt;" & rsPropSearch.Fields.Item("SqFtTotal".Value & "&lt;/td&gt;&lt;/tr&gt;" & vbCRLF _
& Repeat1__index=Repeat1__index+1 & vbCRLF _
& Repeat1__numRows=Repeat1__numRows-1 & vbCRLF _
& rsPropSearch.MoveNext() & vbCRLF _
& Wend & vbCRLF _
If (MM_editRedirectUrl &lt;&gt; "" Then
Response.Redirect(MM_editRedirectUrl)
End If
End If

End If
%&gt;








&lt;!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "www.w3.org/TR/html4/loose.dtd"&gt;
&lt;html&gt;
&lt;head&gt;
&lt;meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"&gt;
&lt;title&gt;Untitled Document&lt;/title&gt;
&lt;/head&gt;

&lt;body&gt;
&lt;p&gt;Dear &lt;%=(rsSearchCriteria.Fields.Item("fullName".Value)%&gt;&lt;/p&gt;
&lt;table width="100%" border="0" cellspacing="1" cellpadding="1"&gt;
&lt;tr&gt;
&lt;td width="27%"&gt;Address&lt;/td&gt;
&lt;td width="16%"&gt;City&lt;/td&gt;
&lt;td width="14%"&gt;Beds&lt;/td&gt;
&lt;td width="30%"&gt;baths&lt;/td&gt;
&lt;td width="13%"&gt;Sq Ft &lt;/td&gt;
&lt;/tr&gt;
&lt;%
While ((Repeat1__numRows &lt;&gt; 0) AND (NOT rsPropSearch.EOF))
%&gt;
&lt;tr&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("StreetNum".Value)%&gt;&lt;img src="../spacer.gif" width="1" height="1"&gt;&lt;%=(rsPropSearch.Fields.Item("StreetName".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("City".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("Beds".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("BathsTotal".Value)%&gt;&lt;/td&gt;
&lt;td&gt;&lt;%=(rsPropSearch.Fields.Item("SqFtTotal".Value)%&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;%
Repeat1__index=Repeat1__index+1
Repeat1__numRows=Repeat1__numRows-1
rsPropSearch.MoveNext()
Wend
%&gt;

&lt;/table&gt;
&lt;p&gt;thanks &lt;/p&gt;
&lt;p&gt;RE/MAX Real Estate &lt;/p&gt;
&lt;/body&gt;
&lt;/html&gt;
&lt;%
rsSearchCriteria.Close()
Set rsSearchCriteria = Nothing
%&gt;
&lt;%
rsPropSearch.Close()
Set rsPropSearch = Nothing
%&gt;

Replied 25 Oct 2004 22:11:14
25 Oct 2004 22:11:14 colin hart replied:
DIGGA
I think I got it
I just need to fine tune it, I had to fiddle with the nested repeats and it seems to write them, now I just need to get them emails.

thanks for the help
Replied 26 Oct 2004 11:01:29
26 Oct 2004 11:01:29 Lee Diggins replied:
No problem Colin, post back if you get stuck.

Digga

Sharing Knowledge Saves Valuable Time!!!

Reply to this topic