<%@ LANGUAGE="VBScript" %> <% Response.Buffer = True %> <% if session("PERSONID") = "" then ' response.redirect "default.asp?caller=dmail.asp" response.redirect "dmcomposepub.asp" end if %> Communication Page <%' %> <%' %> <% strFilter = Request.Querystring("filter") if len(strFilter) = 0 then strFilter = "1" dim aOptList(3) aOptList(1) = "Current Messages" aOptList(2) = "Archived Messages" aOptList(3) = "All Messages" strOptions = "" for lnX = 1 to 3 if CInt(strFilter) = lnX then strOptions = strOptions & "" else strOptions = strOptions & "" end if next session("dMailMode") = "to" set rsStats = GetStats() %>
Compose Message Show: 
<% session("dMailMode") = "from" set rsStats = GetStats() %>

Messages to me

<% set rsMessages = GetMessageListRS(Session("PersonID"), "to") ShowMessages rsMessages, "to" %>

Messages from me

<% set rsMessages = GetMessageListRS(Session("PersonID"), "from") ShowMessages rsMessages, "from" %>
<% function GetMessageListRS(strPersonID, strMode) select case strFilter case "1" ' Current if strMode = "to" then strWhere = "and tdmDistribution.Archived='No' " else strWhere = "and tdmCommunication.Archived='No' " end if case "2" ' Archived if strMode = "to" then strWhere = "and tdmDistribution.Archived='Yes' " else strWhere = "and tdmCommunication.Archived='Yes' " end if case "3" ' All strWhere = "" end select lcSort = Request("hidSort") if len(lcSort) = 0 then lcSort = "32" select case lcSort case "11" lcSorter = "order by tdmCommunication.RequestSubject" case "12" lcSorter = "order by tdmCommunication.RequestSubject desc" case "21" lcSorter = "order by tdmCommunication.RequestFrom" case "22" lcSorter = "order by tdmCommunication.RequestFrom desc" case "31" lcSorter = "order by tdmCommunication.CreatedAt" case "32" lcSorter = "order by tdmCommunication.CreatedAt desc" case "41" lcSorter = "order by tdmCommunication.Subject" case "42" lcSorter = "order by tdmCommunication.Subject desc" case "51" if strMode = "to" then lcSorter = "order by tdmDistribution.Archived desc" else lcSorter = "order by tdmCommunication.Archived desc" end if case "52" if strMode = "to" then lcSorter = "order by tdmDistribution.Archived" else lcSorter = "order by tdmCommunication.Archived" end if end select if strMode = "to" then strSQL = "" strSQL = strSQL & "select tdmCommunication.CommunicationID, tdmCommunication.RequestSubject, " strSQL = strSQL & "tdmDistribution.DistributionID, tdmDistribution.Archived, " strSQL = strSQL & "tdmCommunication.RequestFrom, tdmCommunication.CreatedAt, tdmCommunication.ResponderPassword, tdmCommunication.ParentID " strSQL = strSQL & "from tdmCommunication, tdmDistribution " strSQL = strSQL & "where " strSQL = strSQL & "tdmDistribution.CommunicationID = tdmCommunication.CommunicationID and " strSQL = strSQL & "tdmDistribution.PersonID=" & strPersonID & " " 'and " ' strSQL = strSQL & "tdmCommunication.ParentID = 0 " strSQL = strSQL & strWhere strSQL = strSQL & lcSorter else ' CONN JOIN strSQL = "" strSQL = strSQL & "select tdmCommunication.CommunicationID, tdmCommunication.RequestSubject, " strSQL = strSQL & "tdmCommunication.Archived, tdmCommunication.CreatedAt, " strSQL = strSQL & "tdmCommunication.ResponderPassword, tdmCommunication.ParentID " strSQL = strSQL & "from tdmCommunication, tPerson, tPersonGroup " strSQL = strSQL & "where " strSQL = strSQL & "tdmCommunication.RequestFromPersonGroupID = tPersonGroup.PersonGroupID and " strSQL = strSQL & "tPersonGroup.PersonID = tPerson.PersonID and " strSQL = strSQL & "tPerson.PersonID = " & Session("PersonID") & " " 'and " ' strSQL = strSQL & "tdmCommunication.ParentID = 0 " strSQl = strSQL & strWhere strSQL = strSQL & lcSorter end if set GetMessageListRS = Conn.Execute(strSQL) end function sub ShowMessages(rsMessages, strType) lcSort = Request("hidSort") if len(lcSort) = 0 then lcSort = "32" response.write("") response.write("" & getImage("1", lcSort) & "Subject") if strType = "to" then response.write("" & getImage("2", lcSort) & "From" & "") end if response.write("" & getImage("3", lcSort) & "Sent" & "") response.write("Show") response.write("" & getImage("5", lcSort) & "Archived" & "") response.write("") strColor1 = "#FFFFFF" strColor2 = "#CCFFFF" nCount = 0 do while not rsMessages.EOF if nCount = 0 then strColor = strColor1 nCount = 1 else strColor = strColor2 nCount = 0 end if strArchList = strArchList & ShowThisMessage(strType, strColor) & "," rsMessages.MoveNext loop response.write("") end sub function ShowThisMessage(strType, strColor) strMsg = "" strMsg = strMsg & "" & rsMessages("RequestSubject") & "" if strType <> "from" then if ltrim(rtrim(rsMessages("RequestFrom"))) = "<>" or ltrim(rtrim(len(rsMessages("RequestFrom")))) = 0 then strMsg = strMsg & "(unknown)" else strMsg = strMsg & "" & iUnTag(rsMessages("RequestFrom")) & "" end if end if strMsg = strMsg & "" & rsMessages("CreatedAt") & "" strPersonID = session("PersonID") if strType = "from" then strID = cLng(rsMessages("CommunicationID")) * 18 & "-0-" & rsMessages("ResponderPassword") else strID = cLng(rsMessages("CommunicationID")) * 18 & "-" & strPersonID & "-" & rsMessages("ResponderPassword") end if strLink = "dmshow.asp?id=" & Server.URLEncode(Encrypt(strID)) strMsgLink = "Message" strLink = "dmthread.asp?msgID=" & rsMessages("CommunicationID") strThreadLink = "Thread" strMsg = strMsg & "" & strMsgLink & " " & strThreadLink & "" if strType = "to" then lcArchName = "arch" & left(strType, 2) & rsMessages("DistributionID") else lcArchName = "arch" & left(strType, 2) & rsMessages("CommunicationID") end if strMsg = strMsg & "" if rsMessages("Archived") = "Yes" then strMsg = strMsg & "" else strMsg = strMsg & "" end if strMsg = strMsg & "" response.Write(strMsg & "") ShowThisMessage = lcArchName end function function getImage(strCol, strSort) if strCol = left(strSort, 1) then if mid(strSort, 2, 1) = "1" then strRetVal = "" else strRetVal = "" end if else strRetVal = "" end if getImage = strRetVal end function function getSortString(strCol, strSort) if left(strSort, 1) = strCol then if right(strSort, 1) = "1" then strRetVal = strCol & "2" else strRetVal = strCol & "1" end if else strRetVal = strCol & "1" end if getSortString = strRetVal end function function iUnTag(strString) lcRetVal = ltrim(rtrim(strString)) if left(lcRetVal, 1) = "<" then lcRetVal = "<" & mid(lcRetVal, 2) if right(lcRetVal, 1) = ">" then lcRetVal = left(lcRetVal, len(lcRetVal) - 1) & ">" iUnTag = lcRetVal end function function GetStats() strSQL = "" if session("dMailMode") = "to" then strSQL = strSQL & "select (select count(*) from tdmDistribution where personid = 11 and Archived = 'Yes') as nArchived, " strSQL = strSQL & "(select count(*) from tdmDistribution where personid = " & Session("PersonID") & " and Archived <> 'Yes') as nNotArchived, " strSQL = strSQL & "(select count(*) from tdmDistribution where personid = " & Session("PersonID") & ") as nTotal" else strSQL = strSQL & "select (select count(*) from tdmCommunication where RequestFromPersonGroupID in (select PersonGroupID from tPersonGroup where PersonID = " & Session("PersonID") & " and Archived = 'Yes')) as nArchived, " strSQL = strSQL & "(select count(*) from tdmCommunication where RequestFromPersonGroupID in (select PersonGroupID from tPersonGroup where PersonID = " & Session("PersonID") & " and Archived <> 'Yes')) as nNotArchived, " strSQL = strSQL & "(select count(*) from tdmCommunication where RequestFromPersonGroupID in (select PersonGroupID from tPersonGroup where PersonID = " & Session("PersonID") & ")) as nTotal" end if set GetStats = Conn.Execute(strSQL) end function %>