Example 3
' Set up the table for displaying results. %> <table cellpadding=0> <tr> <td colspan=2><font size=2> <% ' Make introductory sentences match the information displayed. if Request("sh") = "" then L_Match_text = "Here are the messages found matching the query" else L_Match_text = "Here are more messages found matching the query" end if Response.write L_Match_text & "<b> " & DisplayText & "</b>." %> <br> <% if ExchangeViewer="both" then L_OWA_Info = "For Microsoft® Exchange messages, click the author's name to view the message using Microsoft Outlook. Click the <img src=html.gif width=16 height=16 border=0 align=middle align=middle> icon to view the message using Microsoft Outlook Web Access." Response.write L_OWA_Info end if %> <br> </font></td> </tr> </table> <table cellpadding=0 cellspacing=0> <tr bgcolor=cccccc> <% L_KBytes_text = "KB" L_Received_text = "Received" L_Subject_text = "Subject" L_Size_text = "Size" L_From_text = "From" %> <td></td> <td><font size=2><b><% = L_From_text %></b></font></td> <td></td> <td><font size=2><b><% = L_Subject_text %></b></font></td> <td></td> <td><font size=2><b><% = L_Received_text %></b></font></td> <td></td> <td><font size=2><b><% = L_Size_text %></b></font></td> <td></td> </tr> <% ' Set up loop to iterate through results. Do while not RS.EOF ' Determine format type, set up title for and URL for links. if InStr(RS("MimeType"), "text/exch") then DocType="exchange" else DocType="doc" end if ' If message title is blank, use "No subject" instead. if RS("DocTitle") <> "" then Title = RS("DocTitle") else L_Untitled_text = "No subject" Title = L_Untitled_text end if ' Provide alternate text if no author exists. HTMLEncode is ' required to handle author fields with < or >. if RS("DocAuthor") <> "" then Author = Server.HTMLEncode(RS("DocAuthor")) else L_NoAuthor_text = "Author unknown" Author = L_NoAuthor_text end if ' Set up link itself. Link depends on whether item is document or ' Microsoft exchange message. if DocType="doc" then Link = RS("DocAddress") Image = "html.gif" elseif DocType="exchange" then Image = "owa.gif" if ExchangeViewer="owa" then Link = "JavaScript:self.openNewWindow(" & chr(34) & RS("DocAddress") & "&usemainwnd=1" & chr(34) & ", 640,500)" elseif ExchangeViewer="outlook" or ExchangeViewer="both" then Link = "VBScript:self.DisplayMsg(" & chr(34) & RS("DocAddress") & "=1" & chr(34) & ")" end if if ExchangeViewer="both" then OWALink = "JavaScript:self.openNewWindow(" & chr(34) & RS("DocAddress") & "&usemainwnd=1" & chr(34) & ", 640,500)" end if end if %> <% ' Create table row for each result. %> <tr><td> </td></tr> <tr> <% if DEBUGINFO=true or Request("debug") <> "" then %> <% ' Display column with record number. %> <td valign=top><font size=2><% = RecordNum %>.</font></td> <% end if %> <td valign=top> <a href='<% = Link %>'><img src="<% = Image %>" hspace=6 border=0></a> </td> <td width=20% valign=top><font size=2> <a href='<% = Link %>'><b><% = Author %></b></a> <% if ExchangeViewer = "both" and DocType="exchange" then %> <a href='<% = OWALink %>'><img src="html.gif" height=16 width=16 border=0 align=top></a> <% end if %> </font></td> <td width=5> </td> <td width=55% valign=top><font size=2> <b><% = Title %></b> </font></td> <td width=5> </td> <td valign=top nowrap><font size=1> <% = RS("FileWrite") %> </font></td> <td width=5> </td> <td valign=top><font size=1> <% iSize = CInt(CLng(RS("Size"))/1024) %> <% Response.write iSize & " " & L_KBytes_text%> </font></td> </tr> <tr> <td></td> <td colspan=6><font size=2> <table cellpadding=0 cellspacing=0> <td width=30> </td> <td><font size=1> <% = RS("Description") %> </font></td> </tr> </table> </td> </tr> <% ' Increment the results. RS.MoveNext RecordNum = RecordNum + 1 Loop %> <% ' If query times out, display message stating that more results are available. %> <% if Q.QueryTimedOut = TRUE then Response.write "<tr><td></td><td colspan=8><font size=2><b>" L_QueryTimedOut_error = "Not all matching messages were returned. To see all the messages, at the top of the page, click Search again." Response.write " <p>" & L_QueryTimedOut_error Response.write "<b></td></tr><font size=2>" end if %> </table> <hr> <table cellpadding=4> <tr><td><font size=2> <% ' Display a More Results link if there are more results pages. if RS.Properties("MoreRows") = true then Q.StartHit = RS.Properties("NextStartHit") ' Repeat query with new start hit. The query must include any ' custom variables you've used: in this case, Text and RecordNum. Response.write "<a href=search.asp?" _ & Q.QueryToURL & "&" _ & "Category=" & Request("Category") & "&" _ & "DisplayText=" & Server.URLEncode(DisplayText) & "&" _ & "RecordNum=" & RecordNum _ & ">" L_MoreResults_link = "More Results" Response.write L_MoreResults_link & "</a> " end if %> <% ' Display link for a new search. %> <% L_NewSearch_link = "New Search" %> <a href="Search.asp"><% = L_NewSearch_Link %></a> </font></td></tr> </table> <% end if ' End of display of successful search results. %> <% end if ' End of Search Results Section. %> </font> </body> </html>