...

View Full Version : How To send weekly report by mail



bmwmpower
12-18-2006, 10:31 AM
Dear Guys
i was search for way to send weekly report to my member about what happen in my site so this is my idea make function to get Who Was Online this Week and put this function in report and send it by mail
This is my code

Function Active_Members(Last_Report,Current_Report)
Dim Rs
'open connection - returns dbconn as Active connection
Call OpenDbconn()
Set Rs = Server.CreateObject("ADODB.Recordset")
sql=" SELECT Tbl_Member FROM where Last_Visit >= '"& Last_Report &"' And Last_Visit <= '"& Current_Report &"' ORDER BY Last_Visit DESC "
Rs.Open SQL, Dbconn,1,2
If Not rs.EOF then
Do While Not Rs.EOF
%>
<tr bgcolor="#f2f2f2">
<td width="20" align="center" nowrap="nowrap" ><img src="images/icon_user.gif" align="absmiddle" border="0" /></td>
<td align="left" nowrap="nowrap">&nbsp;<% =rs("Name") %></td>
<td align="left" nowrap="nowrap">&nbsp;<% =rs("User_Name") %></td>
<td align="center" nowrap="nowrap">&nbsp;<% =rs("Node") %> </td>
<td align="center" nowrap="nowrap">&nbsp;<% =rs("cluster") %> </td>
<td align="center" nowrap="nowrap">&nbsp;<% =rs("Last_Visit") %></td>
</tr>
<TR><TD bgColor=#cccccc colSpan="6" height=1></TD></TR>
<%
Rs.MoveNext
Loop
Else

%>
<TR><TD colSpan="6" align="center" >(No Active Members)</TD></TR>
<%
end if
'response.Write(sql)
'response.End()
rs.Close
set rs=nothing
call closeDbconn()
End Function


sBody = "<head>" & vbCrLf
sBody = sBody & "<meta http-equiv=""Content-Type"" content=""text/html; charset=iso-8859-1"" />" & vbCrLf
sBody = sBody & "<title>Weekly Report</title>" & vbCrLf
sBody = sBody & "<style type=""text/css"">" & vbCrLf
sBody = sBody & "<!--" & vbCrLf
sBody = sBody & ".Fo_Text_2 { FONT-SIZE: 12px; color:#000000 ; FONT-FAMILY: ""Trebuchet MS"",Verdana, Arial, Helvetica, sans-serif; TEXT-DECORATION: none; FONT-WEIGHT: bold;" & vbCrLf
sBody = sBody & "}" & vbCrLf
sBody = sBody & ".postUsername { FONT-WEIGHT: bold; FONT-SIZE: 12px" & vbCrLf
sBody = sBody & "}" & vbCrLf
sBody = sBody & "-->" & vbCrLf
sBody = sBody & "</style>" & vbCrLf
sBody = sBody & "</head>" & vbCrLf
sBody = sBody & "" & vbCrLf
sBody = sBody & "<body>" & vbCrLf
sBody = sBody & "<span class=""postUsername"">Who Was Online this Week</span>" & vbCrLf
sBody = sBody & "<table width=""733"" border=""0"" cellpadding=""1"" cellspacing=""1"">" & vbCrLf
sBody = sBody & " <tr>" & vbCrLf
sBody = sBody & " <td width=""20"" align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" class=""Fo_Text_2"" >&nbsp;</td>" & vbCrLf
sBody = sBody & " <td class=""Fo_Text_2"" align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" >Name </td>" & vbCrLf
sBody = sBody & " <td class=""Fo_Text_2"" align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" >User Name </td>" & vbCrLf
sBody = sBody & " <td class=""Fo_Text_2"" align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" >Node</td>" & vbCrLf
sBody = sBody & " <td class=""Fo_Text_2""align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" >Cluster</td>" & vbCrLf
sBody = sBody & " <td class=""Fo_Text_2"" align=""center"" nowrap=""nowrap"" background=""http://www.xxx.com/images/table_bg_image.gif"" >Last Visit</td>" & vbCrLf
sBody = sBody & " </tr>" & vbCrLf
sBody = sBody &" " & call Active_Members(Last_Report,Current_Report) &" " & vbCrLf
sBody = sBody & "</table>" & vbCrLf
sBody = sBody & "</body>" & vbCrLf
sBody = sBody & "</html>"

Set SendEmail = Server.CreateObject("SMTPsvg.Mailer")
SendEmail.FromName = " NBCBN Web Master "'Specify sender's address
SendEmail.FromAddress= "Administrator@nbcbn.com"
SendEmail.RemoteHost = "mail.xxxx.com"
SendEmail.AddRecipient "Administrator", "Administrator@xxxx.com"
'SendEmail.AddCC "xxx","s.el-sayed@xxxxx.com"
SendEmail.Subject = sSubject
SendEmail.BodyText = sBody
SendEmail.ContentType ="text/html"
ErrStr = ""

if SendEmail.SendMail Then
ErrStr = "success"
Response.Write "<br><font color=#FF0000 size=3>Message was sent successfully</font><br><br>"
Else
Response.Write "Mail send failure. Error was " & SendEmail.Response
ErrStr="<br><font color=#FF0000 size=3>Mail send failure. Error was </font><br>" & SendEmail.Response

End If



The problem is I get this report by mail but without function Just empty page just html code

Spudhead
12-18-2006, 11:14 AM
Change "Function" to "Sub"


Function Active_Members(Last_Report,Current_Report)
...
End Function

Functions return a value. Subs do stuff. You have a function that's not returning a value, it's trying to do stuff.

bmwmpower
12-18-2006, 11:50 AM
i did that but still not work



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum