<!--#include file="../inc/Secure.htm"-->
<!--#include file="../inc/conn.htm"-->

<%
LoginID=trim(session("LoginID"))
if LoginID="" then LoginID=0
UserName=GetTableValue ("tblUser","Name","ID",LoginID)
strTitle=replace(trim(request("Title")),"'","''")


maxmessage=20
currentpage=request("page")
if currentpage="" then 
currentpage=1
end if

set rs=Server.CreateObject("ADODB.RecordSet")
sql="select ID,isRead,FromName,Subject,Times,AttachFile,body from tblMailin where ToID="& LoginID
if strTitle<>"" then
sql=sql&" and (subject like '%"& strTitle &"%' or body like '%"& strTitle &"%')"
end if
sql=sql& " order by Times desc"

rs.pagesize=maxmessage
rs.open sql,oConn,1,1
totalpage=rs.pagecount
totalmessage=rs.recordcount
if totalmessage<>0 then
	rs.AbsolutePage=currentpage
	msgArr=rs.getrows(maxmessage)
end if

rs.close
%>
<HTML>
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">
</HEAD>
<script language="JavaScript">
function CheckAll(form)
  {
  for (var i=0;i<form.elements.length;i++)
    {
    var e = form.elements[i];
    if (e.name != 'chkall')
       e.checked = form.chkall.checked;
    }
  }
</script>
<BODY BGCOLOR="#FFFFFF">
<table border=0 width="90%">
<tr>
<td><img src="../images/searchmail.gif" border=0></td>
</tr>
</table>
<hr size=1 width="90%" align=left color=#D0D090>
<div align=center>
<Form name="frmSearch" Method="Post" action="<%=Request.ServerVariables("SCRIPT_NAME")%>">
	搜索关键字：
	<INPUT TYPE="text" NAME="Title" size=20 maxlength=40 class="input" value="<%=strTitle%>">
	<INPUT TYPE="submit" Name="cmdSearch" value="Search" class="BoldWhite">
</Form>
</div>
<form name="deletemail" method="post" action="outbox.htm?page=<%=currentpage%>">
<%
response.write "搜索到的邮件 共" & totalmessage & "条/" & totalpage & "页，每页"& maxmessage &"条"
if totalpage>0 then
	response.write "，第" & currentpage & "页　"
end if

if totalpage>1 then
	if currentpage>1 then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?page=<%=currentpage-1%>">上页</a>　　
		<%
	end if

	if currentpage+1<=totalpage then%>
		<a href="<%=Request.ServerVariables("SCRIPT_NAME")%>?page=<%=currentpage+1%>">下页</a>
		<%
	end if
end if
%>
<table border=0 width="100%" bgcolor=#FFFFFF cellpadding=3>
<tr bgcolor=#D0D090>
<td width=10><img src="../images/mail-new.gif" border=0></td>
<td width=3></td>
<td>发件人</td>
<td>主题</td>
<td>日期</td>
<td>附件</td>
</tr>
<%
if isempty(msgArr) then
	response.write "<tr bgcolor=#eeeddb><td colspan=7>该文件夹没有邮件。</td></tr>"
else
for i = 0 to UBound(msgArr,2)
%>
	<tr bgcolor=#eeeddb>
		<td align=center><%if trim(msgArr(1,i))="0" then response.write "<img src='../images/newmail.gif' border=0>"%></td>
		<td></td>
		<td nowrap><a href="mailDetail.htm?ID=<%=trim(msgArr(0,i))%>"><%=trim(msgArr(2,i))%></a></td>
		<td><a href="mailDetail.htm?ID=<%=trim(msgArr(0,i))%>"><%=trim(msgArr(3,i))%></a></td>
		<td><%=trim(msgArr(4,i))%></td>
		<td><%if trim(msgArr(5,i))<>"" then response.write "<img src='../images/attach.gif' border=0 alt='"& trim(msgArr(5,i)) &"'>"%>
		</td>
	</tr>
<%
next
end if
%>

</table>


</form>
<BR><BR>
</BODY>
</HTML>
<%
Function GetTableValue(TableName,Field,ValueField,Value)
	if TableName<>"" and Value<>"" then
		Set RsTmp = Server.Createobject("Adodb.recordset")
		strSql = "Select "& Field &" from "& TableName &" where "& ValueField &"='"& Value &"'"
		Rstmp.open strSql,oConn,1,1
		If not Rstmp.eof then
			GetTableValue=trim(Rstmp(Field))
		else
			GetTableValue=""
		end if
		Rstmp.close
		'set RsTmp = Nothing
	else
		GetTableValue=""
	end if
End Function

Function GetMailIn(ToID, Status, Isread) 
'isRead 0代表未读，1代表已读 Status 0代表正常 1代表已发入垃圾箱 2代表彻底删除
	Set Rstmp = Server.CreateObject("ADODB.RecordSet")
	intMail=0
	strSql = "Select count(id) as intNumber from tblMailIn where ToID ="&ToID &" and Status="& status &" And Isread="& Isread
	RsTmp.Open strSql,oConn
	if not Rstmp.eof then
		intMail=Rstmp("intNumber")
	end if
	Rstmp.close
	set Rstmp = nothing
	GetMailIn=IntMail

End Function
Function GetMailOut(FromID, Status) 'Status 0代表未发出在草稿箱，1代表发出成功
	Set Rstmp = Server.CreateObject("ADODB.RecordSet")
	intMail=0
	strSql = "Select count(ID) as intNumber from tblMailOut where Status="& Status &" and FromID ="&FromID 
	RsTmp.Open strSql,oConn
	if not Rstmp.eof then
		intMail=Rstmp("intNumber")
	end if
	Rstmp.close
	set Rstmp = nothing
	GetMailOut=IntMail

End Function
sub DeleteOneFile (FilePathName)
	FilePathName=Server.Mappath(FilePathName)
	dim fs
	Set fs = server.CreateObject("Scripting.FileSystemObject")
	if trim(FilePathName)<>"" and fs.FileExists(FilePathName) then 
		fs.DeleteFile FilePathName
	end if
	set fs=nothing	
end sub
%>
<!--#include file="../inc/conn_close.htm"-->
<script language=javascript>
function CheckDelete()
{
	return confirm("确实删除吗？");
}
</script>