<!--#include file="../inc/Secure.htm"-->
<!--#include file="../Inc/Conn.htm"-->
<!--#include file="../Inc/def_color.htm"-->
<!--#include file="../Inc/Const.htm"-->
<HEAD>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312">
<link rel="stylesheet" type="text/css" href="../CSS/main.css">

</HEAD>
<%
dim LoginID
LoginID = trim(Session("LoginID"))

IF LoginID="" then 
	LoginID = 0
	oConn.close
	set oConn = Nothing
	Response.End
end if
UserName=GetTableValue ("tblUser","Name","ID",LoginID)


'收件箱
'发件箱
'垃圾箱
'草稿箱
dim nMailInbox, nMailInbox_n, nMailInbox_y, nMailSend, nMailTrash, nMailTrash_y, nMailTrash_n, nMailWait
'nMailInbox,收件箱邮件数 nMailInbox_n,未读 nMailInbox_y,已读 nMailSend,发送的 nMailTrash,垃圾箱 nMailTrash_y 垃圾箱已读, nMailTrash_n,垃圾箱未读 nMailWait 草稿箱

'获取收件箱邮件
nMailInbox_n = GetMailIn (LoginID,0,0)
nMailInbox_y = GetMailIn (LoginID,0,1)
nMailInbox = cint(nMailInbox_n) + cint(nMailInbox_y)

'获取发件箱邮件
nMailSend = GetMailOut (LoginID,1)  '1代表已经发送成功的邮件

'获取垃圾箱邮件
nMailTrash_n = GetMailIn (LoginID,1,0)
nMailTrash_y = GetMailIn (LoginID,1,1)
nMailTrash = cint(nMailTrash_n) + cint(nMailTrash_y)

'获取草稿箱邮件
nMailWait = GetMailOut (LoginID,0) '0代表等待发送的邮件

nTotal=nMailInbox + nMailSend + nMailTrash + nMailWait
nTotal_n=nMailInbox_n + nMailTrash_n
%>
<table border=0 width="90%">
<tr>
<td><img src="../images/folder.gif" border=0></td>
<td> <%=UserName%>，当前您的文件夹中的邮件数：</td>
<td><%=nTotal%></td>
</tr>
<tr>
<td></td><td>其中新邮件数目为</td>
<td><%=nTotal_n%></td>
</tr>
</table>
<hr size=1 width="90%" align=left color=#D0D090>
<div align="left">
<table border="0" cellspacing="2" cellpadding="3" width="80%" bgcolor="#FFFFFF">
  <tr>
    <td align="center" bgcolor="#D0D090"><font color="#0080c0"><b>文件夹</b></font></td>
    <td align="center" bgcolor="#D0D090"><font color="#0080c0"><b>邮件数</b></font></td>
    <td align="center" bgcolor="#D0D090"><font color="#0080c0"><b>新邮件数</b></font></td>
  </tr>

	<tr>
	<td align=center bgcolor=#eeeddb>&nbsp;&nbsp;<font color='#336699'><a href="Inbox.htm">收件箱</a></font></td>
	<td align=center bgcolor=#eeeddb><%=nMailInbox%></td><td align=left bgcolor=#eeeddb>&nbsp;&nbsp;<font color=#ff0000><%=nMailInbox_n%></font></td>
	</tr>
	<tr>
	<td align=center bgcolor=#eeeddb>&nbsp;&nbsp;<font color='#336699'><a href="OutBox.htm">发件箱</a></font></td><td align=center bgcolor=#eeeddb><%=nMailSend%></td><td align=left bgcolor=#eeeddb></td>
	</tr>
	<tr>
	<td align=center bgcolor=#eeeddb>&nbsp;&nbsp;<font color='#336699'><a href="DraftBox.htm">草稿箱</a></font></td>
	<td align=center bgcolor=#eeeddb><%=nMailWait%></td><td align=left bgcolor=#eeeddb></td>
	</tr>
	<tr>
	<td align=center bgcolor=#eeeddb>&nbsp;&nbsp;<font color='#336699'><a href="TrashBox.htm">废件箱</a></font></td>
	<td align=center bgcolor=#eeeddb><%=nMailTrash%></td><td align=left bgcolor=#eeeddb>&nbsp;&nbsp;<font color=#ff0000><%=nMailTrash_n%></font></td>
	</tr>
	
</table>
</div>

<%


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
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
%>

<!--#include file="../Inc/Conn_close.htm"-->