帮我看一下代码,急!!!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>
...全文
108 23 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
23 条回复
切换为时间正序
请发表友善的回复…
发表回复
xjd5555 2002-05-22
  • 打赏
  • 举报
回复
恭喜!
hhfh 2002-05-22
  • 打赏
  • 举报
回复
删除:
if trim(con(p+2))>"" then
strFile=replace(con(p+2),"%20","")
我改为strFile=trim(replace(con(p+2),"%20",""))
fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+strFile
删除通过!
谢谢了
hhfh 2002-05-22
  • 打赏
  • 举报
回复
打开附件可以了!谢谢\!
删除附件时的错误 帮我解决一下
hhfh 2002-05-21
  • 打赏
  • 举报
回复
haish还是不可以,急死人了
tripofdream 2002-05-21
  • 打赏
  • 举报
回复
var tempStr=kk.substring(kk.lastIndexOf("/")+1);
tempStr=tempStr.replace(/%20/g,"");
fujian.innerHTML="<a target=_black href='" + fj[obj.selectedIndex] + "'>" + tempStr;

删除:
if trim(con(p+2))>"" then
strFile=replace(con(p+2),"%20","")
fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+strFile

"%20"有可能是在发邮件时产生的.
tripofdream 2002-05-21
  • 打赏
  • 举报
回复
删除附件时的错误跟这个不一样.
strFile中已经包含了路径(还多了邮箱名).
hhfh 2002-05-21
  • 打赏
  • 举报
回复
我还没试,那删除附件的呢?!
tripofdream 2002-05-21
  • 打赏
  • 举报
回复
var tempStr=fj[obj.selectedIndex];
tempStr=tempStr.replace(/ /g,"");
fujian.innerHTML="<a target=_black href='" + tempStr + "'>" + kk.substring(kk.lastIndexOf("/")+1);
hhfh 2002-05-20
  • 打赏
  • 举报
回复
打开附件的代码为:
......
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)

}
......

<td width="100%" height="20">
<p align="left">附件:<span id=fujian></span>
</td>
......
怎么去掉空格,在function set(obj)函数中,我不知这用什么语言写的!?
hhfh 2002-05-20
  • 打赏
  • 举报
回复
打开附件的代码为:
......
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)

}
......

<td width="100%" height="20">
<p align="left">附件:<span id=fujian></span>
</td>
......
怎么去掉空格,在function set(obj)函数中,我不知这用什么语言写的!?
hhfh 2002-05-20
  • 打赏
  • 举报
回复
以下是一收件箱代码,问题是不能删除有附件的邮件,没附件的能删除!删除附件的代码为: 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)
hhfh 2002-05-20
  • 打赏
  • 举报
回复
不可以!还是有空格符20%20%20%20%20%20%20%
c中哪个函数清空格?!
还有删除附件时:不能删除有附件的邮件,没附件的能删除!删除附件的代码为: if trim(con(p+2))>"" then fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+con(p+2))
也有有空格符20%20%20%20%20%20%20%
hhfh 2002-05-20
  • 打赏
  • 举报
回复
不可以!还是有空格符20%20%20%20%20%20%20%
c中哪个函数清空格?!
还有删除附件时:不能删除有附件的邮件,没附件的能删除!删除附件的代码为: if trim(con(p+2))>"" then fs.deletefile("d:\inetpub\wwwroot\我的网页\email\"+session("单位")+"\"+con(p+2))
也有有空格符20%20%20%20%20%20%20%
tripofdream 2002-05-20
  • 打赏
  • 举报
回复
try:
var tempStr=kk.substring(kk.lastIndexOf("/")+1);
tempStr=tempStr.replace(/ /g,"");
fujian.innerHTML="<a target=_black href='" + fj[obj.selectedIndex] + "'>" + tempStr;
lovingkiss 2002-05-17
  • 打赏
  • 举报
回复
那些%是汉字的编码呀,建议别用汉字的名称,支持不好的;
ywz413 2002-05-17
  • 打赏
  • 举报
回复
浏览器解析地址解析汉字的时候要用到一个函数escape,格式是escape(汉字),你这样试一试。对了 如果行了的话给分。还有20%是空格 把空格看能不能消掉
tripofdream 2002-05-17
  • 打赏
  • 举报
回复
空格有可能是在产生附件地址(发邮件时)时产生,也可能是读附件地址时产生,贴出跟附件有关的代码(从发邮件开始),略去其它代码.
hhfh 2002-05-17
  • 打赏
  • 举报
回复
http://goldsoft/email/办公室/%20%20%20%20%20%20%20%20read.txt
我的问题是怎么多了20%20%20%20%20%20%20%20这些字符串,附件地址栏显示的也多了20%20%20%20%20%20%20%20这些字符串
tripofdream 2002-05-17
  • 打赏
  • 举报
回复
你这两个问题其实是同一个问题,找不到文件当然就不能删除.
需要从发邮件开始查看附件地址不正确的原因.
hhfh 2002-05-17
  • 打赏
  • 举报
回复
还有附件打不开,打开的地址如: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)
to lovingkiss(你要答案我要分) 我没用中文名也有20%20%20%20%20%20%20%
这怎么办!
怎么去掉空格!?
加载更多回复(3)

28,409

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧