home *** CD-ROM | disk | FTP | other *** search
/ bombers.k12.ar.us / bombers.k12.ar.us.tar / bombers.k12.ar.us / survey / SendReportShareMessageAction.asp < prev    next >
Text File  |  2006-11-29  |  7KB  |  180 lines

  1. <!--#Include File="Include/Top_inc.asp"-->
  2. <%
  3. '***********************************************************************
  4. '   Application: SelectSurveyASP Advanced v8.1.11
  5. '   Author: Aaron Baril for ClassApps.com
  6. '   Page Description: This page is called from SendReportShareMessage.asp and sends the emails
  7. '                      for the data input on the previous page.
  8. '
  9. '   COPYRIGHT NOTICE                                
  10. '
  11. '   See attached Software License Agreement
  12. '
  13. '   (c) Copyright 2002 - 2006 by ClassApps.com.  All rights reserved.
  14. '***********************************************************************
  15.  
  16.     'Buffering must be on for sending emails
  17.     Response.Buffer = True
  18.     Server.ScriptTimeout = 1500
  19.  
  20.     Dim lngSurveyID
  21.     Dim rsReportShare
  22.     Dim strSQL
  23.     Dim strEmailAddresses
  24.     Dim conReportShare
  25.     Dim arrEmailAddresses
  26.     Dim flgEmailInHTMLFormat
  27.     Dim i
  28.     Dim lngEmailSentCount
  29.     Dim strTempURL
  30.     Dim strBody
  31.     Dim strSentEmailAddresses
  32.     Dim strReportShareURLID
  33.             
  34.     'Initialization
  35.     lngSurveyID = Request.Form("SurveyID")
  36.     Set rsReportShare = Server.CreateObject("ADODB.Recordset")
  37.     Set conReportShare = Server.CreateObject("ADODB.Connection")
  38.     conReportShare.Open SURVEY_APP_CONNECTION
  39.     If Request.Form("chkHTMLFormat") = "on" Then
  40.         flgEmailInHTMLFormat = True
  41.     Else
  42.         flgEmailInHTMLFormat = False
  43.     End If
  44.     lngEmailSentCount = 0
  45.  
  46.     'If the user does not either own this survey or have admin permission, deny them access to this functionality.
  47.     If IsUserOwnerOrAdmin(lngSurveyID) = False Then
  48.         Response.Redirect "AccessDenied.asp?Reason=" & SUR_ACCESS_DENIED_NOT_OWNER_FOR_RESULTS_SHARING
  49.     End If
  50.     
  51.     'Get the unique ID and the list of email addresses for this report share
  52.     strSQL = "SELECT report_share_url_id, email_addresses " & _
  53.              "FROM sur_report_share " & _
  54.              "WHERE report_share_id = " & Request.Form("ReportShareID")
  55.     rsReportShare.Open ConvertSQL(strSQL), conReportShare, adOpenForwardOnly, adLockReadOnly, adCmdText
  56.     rsReportShare.MoveFirst
  57.     strReportShareURLID = rsReportShare("report_share_url_id")
  58.     strEmailAddresses = rsReportShare("email_addresses")
  59.     rsReportShare.Close
  60.     Set rsReportShare = Nothing
  61.     
  62.     'Loop through each of the email addresses, and send an email
  63.     arrEmailAddresses = Split(strEmailAddresses, ";")
  64.     For i = 0 To UBound(arrEmailAddresses)
  65.         'Get the URL to use to link to the survey
  66.         strTempURL = SUR_APPLICATION_ROOT_URL & "/ResultsOverview.asp?SID=" & strReportShareURLID
  67.         If flgEmailInHTMLFormat = True Then
  68.             strTempURL = "<a href=""" & strTempURL & """>" & strTempURL & "</a>"
  69.         End If
  70.         
  71.         'Get the text of the email, and replace the token for the link to the survey
  72.         strBody = Replace(Request.Form("txtEmailText"), "#SurveyLink#", strTempURL)
  73.  
  74.         'Send the email
  75.         SendMail Trim(arrEmailAddresses(i)), Request.Form("txtFromAddress"), Request.Form("txtCCAddress"), Request.Form("txtBCCAddress"), strBody, Request.Form("txtSubject"), flgEmailInHTMLFormat
  76.         
  77.         'Track the list of sent email addresses
  78.         strSentEmailAddresses = strSentEmailAddresses & Trim(arrEmailAddresses(i)) & "; "
  79.         
  80.         'Track the number of emails sent
  81.         lngEmailSentCount = lngEmailSentCount + 1
  82.                             
  83.         'Insert a record into the database recording the sent email
  84.         strSQL = "UPDATE sur_report_share " & _
  85.                  "SET last_sent_date = GETDATE() " & _
  86.                  "WHERE report_share_id = " & Request.Form("ReportShareID")
  87.         conReportShare.Execute ConvertSQL(strSQL), , adCmdText
  88.     Next
  89.  
  90.     'Strip the trailing semi-colon and space off the list of sent email addresses
  91.     strSentEmailAddresses = Left(strSentEmailAddresses, Len(strSentEmailAddresses) - 2)
  92.     
  93.     'Clean up
  94.     conReportShare.Close
  95.     Set conReportShare = Nothing
  96. %>
  97. <!--#Include File="Include/SurveyUtility_inc.asp"-->
  98. <!--#Include File="Include/Utility_inc.asp"-->
  99. <!--#Include File="Include/Constants_inc.asp"-->
  100. <!--#Include File="Include/Config_inc.asp"-->
  101. <!--#Include File="Include/ID_inc.asp"-->
  102. <!--#Include File="Include/Email_inc.asp"-->
  103. <!--#Include File="Include/adovbs_inc.asp"-->
  104. <!--#Include File="Include/CurrentUser_inc.asp"-->
  105. <!--#Include File="Include/SurveySecurity_inc.asp"-->
  106. <!--#Include File="Include/Encryption_inc.asp"-->
  107.  
  108. <html>
  109. <head>
  110.     <title>Send Report Share Message Confirmation</title>
  111.     <link rel="stylesheet" href="Resources/StyleSheet/SurveyStyle.css">
  112. </head>
  113.  
  114. <body class="MainBodyStyle">
  115.  
  116. <!--#Include File="Include/FrameworkTop_inc.asp"-->
  117.  
  118. <table border="0" cellspacing="0" cellpadding="0" width="754" class="MediumBlueBackgroundColor">
  119.     <tr>
  120.         <td height="36" valign="center">
  121.               <span class="H1HeadingStyle"><a name="skipnav" tabindex="1">Send Report Share Message</a></span> <img style="cursor:hand" alt="Help" onClick="javascript:window.open('Help/Help.htm#ResultsSharing', null, 'menubar=no,toolbar=no,titlebar=no,status=no,left=10,top=10,scrollbars=yes,resizable=yes,height=550,width=770');" border="0" src="Resources/Images/Help.gif">
  122.         </td>
  123.     </tr>
  124. </table>
  125.  
  126. <!--#Include File="Include/FrameworkTop2_inc.asp"-->
  127.  
  128. <table width="740" border="0" cellpadding="0" cellspacing="6" class="LightGrayBackgroundColor">
  129.     <tr>
  130.         <td width="1"></td>
  131.         <td height="40" valign="center">
  132.             <span class="H2HeadingStyle">Report Share Message Sent for Survey '<%=Request.Form("SurveyName")%>'</span>
  133.         </td>
  134.         <td width="1" rowspan="2"> </td>
  135.     </tr>
  136. </table>
  137. <table border="0" cellpadding="0" cellspacing="0" width="100%"><tr><td height="1" background="Resources/Images/ThinDivider.gif"></td></tr></table>
  138. <table border="0" cellpadding="0" cellspacing="6" width="740" class="WhiteBackgroundColor">
  139.     <tr>
  140.         <td width="1" rowspan="10"></td>
  141.         <td>
  142.             <br>
  143.             <span class="Normal">
  144. <%
  145.                 If lngEmailSentCount = 1 Then
  146. %>
  147.                     One email was sent to the following email address:
  148. <%
  149.                 Else
  150. %>
  151.                     A total of <%=lngEmailSentCount%> emails were sent to the following email addresses:
  152. <%
  153.                 End If
  154. %>
  155.                 <br><br>
  156.                 <%=strSentEmailAddresses%>
  157.             </span>
  158.             <br>
  159.         </td>
  160.         <td width="1" rowspan="10"></td>
  161.     </tr>
  162.     <tr>
  163.         <td align="right">
  164.             <br><br>
  165.             <a href="ReportShareList.asp?SurveyID=<%=lngSurveyID%>&SurveyName=<%=Request.Form("SurveyName")%>"><img border="0" alt="Click to return to the list of report shares for this survey" src="Resources/Buttons/OK.gif" name="btnOK"></a>
  166.         </td>
  167.     </tr>
  168.         
  169. </table>
  170.  
  171. <!--#Include File="Include/FrameworkBottom_inc.asp"-->
  172.  
  173. </body>
  174. </html>
  175.  
  176. <%        
  177.     'Ensure that the web server returns the page
  178.     Response.Flush
  179. %>
  180.