帮我看一下代码,急!!!50分大放送
hhfh 2002-05-17 12:35:48 以下是一收件箱代码,问题是不能删除有附件的邮件,没附件的能删除!删除附件的代码为: if trim(con(p+2))>"" then fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+con(p+2))
还有附件打不开,打开的地址如:http://goldsoft/email/办公室/%20%20%20%20%20%20%20%20read.txt,read.txt前多了20%20%20%20%20%20%20%,把这“20%20%20%20%20%20%20%”去掉就可以看得到!
打开附件的代码为:
fujian.innerHTML="<a target=_black href='" + fj[obj.selectedIndex] + "'>" + kk.substring(kk.lastIndexOf("/")+1)
全部代码如下:帮我看一下!
<%
if session("姓名")="" or session("单位")="" then response.redirect ("inbox.asp")
Dim fs, f, s, fp,fname
Set fs = CreateObject("Scripting.FileSystemObject")
fname="d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+session("姓名")+".~~~"
'接收全部邮件
Set f = fs.openTextFile(fname,1,1)
Set fp =fs.getfile (fname)
if fp.size>0 then s=f.readall else s=""
f.close
'解析数据
Set d = CreateObject("Scripting.Dictionary")
start=1
cc=0
do while start<len(s)
d.add cc,string(s,start,12)
d.add cc+1,string(s,start,200)
d.add cc+2,string(s,start,100)
d.add cc+3,string(s,start,8)
d.add cc+4,string(s,start,1000)
cc=cc+5
loop
'删除全部邮件
if request.form("ACT")="全部删除" then
con=d.items
for p= 0 to d.count-1 step 5
'删除附件
if trim(con(p+2))>"" then fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+con(p+2))
next
d.removeall '删除集合中的数据
fs.deletefile(fname) '删除邮件数据文件
end if
'删除单个邮件
if request.form("ACT")="删 除" then
con=d.items
'删除附件
if trim(con(request("index")*5+2))>"" then fs.deletefile("d:\inetpub\wwwroot\机务处\email\"+session("单位")+"\"+con(request("index")*5+2))
'删除集合中的数据
d.remove(request("index")*5)
d.remove(request("index")*5+1)
d.remove(request("index")*5+2)
d.remove(request("index")*5+3)
d.remove(request("index")*5+4)
Set f = fs.CreateTextFile(fname,1) '重新写回邮件
con=d.items
for p= 0 to d.count-1
f.write con(p)
next
f.close
end if
function string(str,start,bytes) '此函数返回相当于指定字节的字符串
string=""
do while count< bytes
c=mid(str,start,1)
if c< CHR(128) then count = count + 1 else count = count + 2
start = start + 1
string = string + C
loop
end function
con=d.items
%>
<head>
<style>
h1{font:600 32;margin:0,0,0,0;color:red;text-align:center}
h6{font: 12;margin:0,0,0,0}
form{margin:0,0,0,0}
</style>
<script>
fj=new Array
<% for p= 0 to d.count-1 step 5 %>
<% con(p+2)="email/" & session("单位") & "/" & con(p+2) %>
fj[<%=p\5%>]="<%= con(p+2) %>"
<% next %>
function set(obj)
{
if (obj.selectedIndex==LST.length-1){return}
content.value=obj.value
kk=fj[obj.selectedIndex]
fujian.innerHTML="<a target=_black href='" + fj[obj.selectedIndex] + "'>" + kk.substring(kk.lastIndexOf("/")+1)
}
</script>
</head>
<body bgcolor=rgb(255,223,143) onload="count.innerHTML=LST.length-1">
<table ID=F2 border="1" width="100%">
<tr>
<td width="100%" align="center" height="100%">
<table border="0" width="95%" height="57" cellspacing="4" cellpadding="0">
<tr>
<td width="34%" height="51" align=right valign="bottom">
<h6 align="center">共<span id=count></span>封信</h6>
</td>
<td width="33%" height="51" align=center>
<h1> 收 件 箱 </h1>
</td>
<td width="33%" height="51" align=center valign="bottom">
<p align="center"><input type="submit" value=" 发件箱 " name="B1" onclick=document.location.replace("outbox.asp")>
</td>
</tr>
</table>
<table border="0" width="90%" cellspacing="4" cellpadding="0">
<tr>
<td width="100%">
<p align="center">
<select size="5" name="LST" onclick=set(this)>
<% for p= 0 to d.count-1 step 5 %>
<option value="<%= rtrim(con(p+4)) %>"><%= con(p) %>: <%= con(p+1) %>
(<%= con(p+3) %>) <% next %>
<option>
</select></p>
</td>
</tr>
</table>
<table border="0" width="90%" cellspacing="4" cellpadding="0">
<tr>
<td width="100%">
<p align="center"><textarea rows="8" name="content" cols="60"></textarea></p>
</td>
</tr>
</table>
<table border="0" width="80%" cellspacing="4" cellpadding="0">
<tr>
<td width="100%" height="20">
<p align="left">附件:<span id=fujian></span>
</td>
</tr>
</table>
<form method=post>
<table border="0" width="90%" cellspacing="4" cellpadding="0">
<tr>
<td width="100%" height="20">
<p align="right"><input type="hidden" value="" name="index"><input type="submit" value="删 除" name="ACT" onclick=index.value=LST.selectedIndex><input type="submit" value="全部删除" name="ACT" >
</td>
</tr>
</table>
</form>
</td>
</tr>
</table>