home *** CD-ROM | disk | FTP | other *** search
/ Chip 1998 March / CHIPCD_3_98.iso / software / testsoft / exchange / webdata / usa / forms / report / commands.asp next >
Text File  |  1997-08-25  |  8KB  |  256 lines

  1. <!--#include file="../../constant.inc"-->
  2. <!--#include file="../../lib/session.inc"-->
  3. <!--#include file="../../lib/store.inc"-->
  4. <!--#include file="../../lib/delete.inc"-->
  5. <!--#include file="reptext.inc"-->
  6. <!--#include file="../../lib/jsutil.inc"-->
  7. <%
  8. '<!--Microsoft Outlook Web Access-->
  9. '<!--Report.* commands.asp
  10. '<!--Copyright (c) Microsoft Corporation 1993-1997. All rights reserved.-->
  11.  
  12. On Error Resume Next
  13.  
  14. 'Handles two commands:  delete, forward
  15.  
  16. urlCommand = Request.QueryString("command")
  17. bstrObj = Request.QueryString("obj")
  18.  
  19. bstrCommand = urlCommand
  20. bstrSaveCopy = Request.QueryString("savecopy")
  21.  
  22. CheckSession2 bstrVirtRoot + "/forms/report/commands.asp" _
  23.               + "?command=" + bstrCommand + "&obj=" + bstrObj + "&timedout=1"
  24.  
  25. isResolved = True
  26. bstrBodyTag = "<body text=000000 onLoad=""statusAlert()"">"
  27. bstrNewObj = ""
  28. bstrFormPath = ""
  29. Select Case  bstrCommand   
  30.     
  31.     Case "forward"
  32.         Set objMsg = GenerateResponse(bstrCommand, bstrNewObj, bstrFormPath, bstrBodyTag) 
  33.         'Need to change the type else the forwarded message will appear as a report also
  34.         objMsg.Type="IPM.Note"
  35.     
  36.     Case "delete"
  37.         Err.Clear
  38.         OpenAllStores
  39.         DeleteItemByID bstrObj, False
  40.         If Err.Number <> 0 Then
  41.             ReportError1 L_errFailDeleteMessage_ErrorMessage
  42.         Else
  43.             Set Session(bstrObj) = Nothing
  44.             RemoveIDFromCache(bstrObj)
  45.             bstrBodyTag = "<body onLoad=""self.close()"">"
  46.         End If
  47.  
  48.     Case "cancel"
  49.         'If the user canels then dismiss the window and kill the session object
  50.         Set Session(bstrObj) = Nothing
  51.         RemoveIDFromCache(bstrObj)
  52.         bstrBodyTag = "<body onLoad=""self.close()"">"
  53.  
  54.     End Select
  55.  
  56.  
  57.  
  58. Function GenerateResponse(bstrResponseType, bstrNewObj, bstrFormPath, bstrBodyTag)
  59.     On Error Resume Next
  60.     Set objOneMsg = Session(bstrObj)
  61.     
  62.     If objOneMsg Is Nothing then
  63.       Set objOneMsg = OpenMessage(bstrObj)
  64.     End If
  65.             
  66.     If objOneMsg.ID = "" Then
  67.         bstrError = "<b>" + L_Error_ErrorMessage + "<br><br>" _
  68.         + L_errFailOpenMessage_ErrorMessage + "</b><br>" _
  69.         + L_errMessageDeleted_ErrorMessage
  70.     End If
  71.  
  72.     'Create a new message in memory
  73.     Randomize
  74.     bstrNewObj = cstr(int(100000 * Rnd()))
  75.     bstrFormPath = "frmRoot.asp"
  76.     bstrBodyTag = "<body text=000000 onLoad=""LaunchForm('" + bstrFormPath + "')"">"
  77.     
  78.  
  79.         Set objNewMsg = objOneMsg.Forward
  80.     objNewMsg.Subject = ""
  81.  
  82.     InitResponse objOneMsg, objNewMsg, bstrResponseType
  83.     Set Session(bstrNewObj) = objNewMsg
  84.     AddIDToCache(bstrNewObj)
  85.  
  86.     'Delete source message in memory
  87.     Set Session(bstrObj) = Nothing
  88.     RemoveIDFromCache(bstrObj)
  89.     Set GenerateResponse = objNewMsg    
  90. End Function
  91.  
  92.  
  93. Sub InitResponse (srcMsg, newMsg, bstrResponsetype)
  94.     On Error Resume Next
  95.     If bstrResponsetype = "forward" then
  96.        bstrSubjectPrefix = L_ForwardPrefix_Text
  97.     Else
  98.        bstrSubjectPrefix = L_ReplyPrefix_Text
  99.     End If
  100.     strReportType = Right(srcMsg.Type, 3)
  101.  
  102.     lSensitivity = 0
  103.     lSensitivity = srcMsg.Fields.Item(ActMsgPR_SENSITIVITY)
  104.     Select Case lSensitivity
  105.         Case 0
  106.         'Normal
  107.             bstrSensisitivity = ""
  108.         Case 1
  109.             'Personal
  110.             bstrSensisitivity = L_HeaderSensitivity_Text & " " & L_Personal_Text & vbCrLf
  111.         Case 2
  112.             'Private
  113.             bstrSensisitivity = L_HeaderSensitivity_Text & " " & L_Priv_Text & vbCrLf
  114.         Case 3
  115.             'Confidential
  116.             bstrSensisitivity = L_HeaderSensitivity_Text & " " & L_Confidential_Text & vbCrLf
  117.     End Select
  118.     lImportance = srcMsg.Importance
  119.  
  120.     If lImportance = ActMsgHigh then
  121.         bstrImportance = L_HeaderImportance_Text & " " & L_High_Text & vbCrLf
  122.     ElseIf lImportance = ActMsgLow then
  123.         bstrImportance = L_HeaderImportance_Text & " " & L_Low_Text & vbCrLf
  124.     Else
  125.         bstrImportance = ""
  126.     End If
  127.     bstrConversation = srcMsg.Fields.Item(ActMsgPR_CONVERSATION_TOPIC)
  128.     
  129.     
  130.     newMsg.ConversationIndex = objOMSession.CreateConversationIndex(srcMsg.ConversationIndex)
  131.     newMsg.Sensitivity = srcMsg.Sensitivity
  132.     newMsg.Categories=srcMsg.Categories
  133.     newMsg.DeliveryReceipt = False
  134.     newMsg.ReadReceipt = False
  135.     If bstrResponseType <> "forward" then
  136.         newMsg.Importance = 1
  137.      End If
  138.     
  139.     If bstrConversation <> "" then
  140.         bstrConversationDisplay = L_HeaderConversation_Text & " " & bstrConversation & vbCrLf
  141.     Else
  142.         bstrConversationDisplay = ""
  143.     End If
  144.  
  145.     bstrMessageData = " " & vbCrLf &  vbCrLf & "-----" & L_OriginalMessage_Text & "-----" & vbCrLf 
  146.  
  147.     bstrBodyTO = ""
  148.     bstrBodyCC = ""
  149.     If strReportType = "NDR" Then
  150.         ' ActMsgPR_RECEIVED_BY_NAME
  151.         If srcMsg.Fields.Item(&H0044001F) <> "" then  ' PR_RCVD_REPRESENTING_NAME
  152.             bstrBodyTO = L_HeaderTO_Text & " " & srcMsg.Fields.Item(&H0044001F) & vbCrLf
  153.         End If
  154.     Else
  155.         ' ActMsgPR_DISPLAY_TO
  156.         If srcMsg.Fields.Item(ActMsgPR_DISPLAY_TO) <> "" then
  157.             bstrBodyTO = L_HeaderTO_Text & " " & srcMsg.Fields.Item(ActMsgPR_DISPLAY_TO) & vbCrLf
  158.         End If
  159.  
  160.         ' ActMsgPR_DISPLAY_CC
  161.         If srcMsg.Fields.Item(ActMsgPR_DISPLAY_CC) <> "" then    '
  162.             bstrBodyCC = L_HeaderCC_Text & " " & srcMsg.Fields.Item(ActMsgPR_DISPLAY_CC) & vbCrLf
  163.         End If
  164.     End If
  165.  
  166.     ' ActMsgPR_SENT_REPRESENTING_NAME
  167.     If srcMsg.Fields.Item(ActMsgPR_SENT_REPRESENTING_NAME) <> "" Then
  168.         bstrBodyFROM = L_HeaderFrom_Text & " " & srcMsg.Fields.Item(ActMsgPR_SENT_REPRESENTING_NAME) & vbCrLf
  169.     Else
  170.         bstrBodyFROM = ""
  171.     End If
  172.  
  173.  
  174.     ' ActMsgPR_NORMALIZED_SUBJECT
  175.     
  176.     bstrSubjectData = bstrSubjectPrefix & srcMsg.Fields.Item(ActMsgPR_NORMALIZED_SUBJECT)
  177.     bstrBodySent     = L_HeaderSENT_Text & " " & srcMsg.Fields.Item(ActMsgPR_CLIENT_SUBMIT_TIME)  & vbCrLf
  178.     bstrMessageData  = bstrMessageData & bstrBodyFrom & bstrBodyTo & bstrBodyCC
  179.     bstrMessageData  = bstrMessageData & bstrBodySent
  180.     
  181.     bstrSubject = srcMsg.Subject
  182.     If bstrSubject <> "" then
  183.         bstrSubject = L_HeaderSubject_Text & " " & bstrSubject & vbCrLf
  184.     End If
  185.     bstrMessageData  = bstrMessageData & bstrSubject  & bstrImportance & bstrSensisitivity
  186.     bstrMessageData  = bstrMessageData & vbCrLf
  187.  
  188.     ' the original message has no text if it's an NDR
  189.     ' otherwise, it has hacked text created by Kluane's read form
  190.     If strReportType <> "NDR" Then
  191. '        newMsg.Text = bstrMessageData
  192. '        newMsg.Text = newMsg.Text + srcMsg.Text
  193.         bstrMessageData = bstrMessageData & srcMsg.Text
  194.         newMsg.Text = bstrMessageData
  195.     Else
  196.         bstrRecipText = GetNDRBody(srcMsg, True)
  197.         newMsg.Text = bstrMessageData & bstrRecipText
  198.     End If
  199.  
  200.     newMsg.Subject = bstrSubjectData
  201.  
  202. End Sub
  203.  
  204.  
  205. %>
  206.  
  207. <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 3.2//EN">
  208. <HTML>
  209. <HEAD>
  210. <script language='javascript'>
  211. var holdMinutes=5;
  212. var holdMs=60000 * holdMinutes; //5 min we could get the current session timeout if we felt like it?
  213.  
  214. function holdSession() {
  215.   setTimeout("self.location='commands.asp?command=holding'",holdMs);
  216. }
  217.  
  218.  
  219. <% if urlCommand="holding" then %>
  220.   parent.fLockForm = true;
  221.   setTimeout("self.location='commands.asp?command=holding'",holdMs);
  222. <% else %>
  223.   parent.fLockForm = false;
  224. <% end if %>
  225.  
  226. function statusAlert() {
  227. <% If Not isResolved Then %>
  228.    DisplayNames();
  229.  
  230. <%Else%>
  231.     <% If bstrCommand="send" Then%>
  232.         parent.close();
  233.     <%ElseIf bstrCommand="bind" Then%>
  234.         parent.gotoForm(parent.iNextForm);
  235.     <%ElseIf bstrCommand="save" Then%>
  236.         top.status = "<%=L_MessageSaved_Message%>";
  237.     <% end if %>
  238. <%End If%>
  239. }
  240.  
  241. <%If Not isResolved Then %>
  242. var _ANRWindow=null;
  243. function DisplayNames() {
  244.     _ANRWindow = window.open("<%=bstrVirtRoot%>/forms/amunres.asp?obj=<%=bstrObj%>","anrWindow","width=400,height=300,scrollbars=1,resizable");
  245. }
  246. <%End If%>
  247. function LaunchForm(szFormPath) {
  248.   openNewWindow("<%=bstrVirtRoot%>/forms/ipm/note/"+szFormPath + "?command=new&obj=<%=bstrNewObj%>",'newMessageWindow',640,500);
  249.   self.close();
  250. }
  251. </script>
  252. <TITLE>Commands</TITLE>
  253. <%=bstrBodyTag%>
  254. </body>
  255. </HTML>
  256.