使用asp实现支持附件的邮件系统(一) 

大家经常探讨使用asp,而不使用其他组建能否实现文件的上传,从而开发出支持邮件附件的邮件系统,答案是可以的。请看:

以下是发送邮件的页面,邮件的帐号是员工号,假设是5位的数字,sendmail.asp当然是在合法登陆后才能够看到的

 1<html>
 2<head>
 3<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 4<link href="/css/FORUM.CSS" rel="stylesheet" type="text/css"/>
 5<style type="text/css">   
 6<!--   
 7input { font-size: 9pt; color: #0011dd; background-color: #e9e9f9; padding-top: 0px}   
 8select { font-size: 9pt; color: #0011dd; background-color: #e9e9f9; padding-top: 0px}   
 9textarea { font-size: 9pt; color: #0011dd; background-color: #e9e9f9; padding-top: 0px}   
10\-->   
11</style>
12<title>邮件系统</title></head>
13<body bgcolor="#FEF7ED">
14<script language="javascript">   

if session("myid")="" or len(session("myid"))<>5 then
response.write "window.open('nolog.asp',target='_top');"
end if

 1function check(theform)   
 2{   
 3  
 4if (theform.geterempl.value=='')   
 5{   
 6alert('请输入收件人!');   
 7theform.geterempl.focus();   
 8return false;   
 9}   
10if (theform.emailtitle.value=='')   
11{   
12alert('请输入主题!');   
13theform.emailtitle.focus();   
14return false;   
15}   
16if (theform.emailtitle.value.length>200)   
17{   
18alert('主题请少于200字节');   
19theform.emailtitle.focus();   
20return false;   
21}   
22if (theform.body.value.length>15*1024)   
23{   
24alert('正文请少于16K');   
25theform.body.focus();   
26return false;   
27}   
28if (theform.emailshowname.value.length>1024)   
29{   
30alert('签名请少于1K');   
31theform.emailshowname.focus();   
32return false;   
33}   
34  
35  
36}   
37</script>   

meth=request.querystring("meth")
if meth=1 then
geterempl=trim(request.querystring("geterempl"))
emailtitle=trim(request.querystring("emailtitle"))
elseif meth=2 then
mailid=trim(request.querystring("mailid"))
set conn=server.createobject("adodb.connection")
conn.open "DSN=;UID=;PWD="
dsnpath="DSN=;UID=;PWD="
set rs=server.createobject("adodb.recordset")

selectnew="select * from t_mail where ((geterempl like '%"&amp;session("myid")&amp;"%' or deleempl like '%"&amp;session("myid")&amp;"%' or receempl like '%"&amp;session("myid")&amp;"%')and (not deleverempl like '%"&amp;session("myid")&amp;"%')) and mailid='"&amp;mailid&amp;"' "
rs.open selectnew,dsnpath,3,3
if rs.bof or rs.eof then

1<script language="javascript">   
2alert("您没有查看这封邮件的权限!");   
3window.history.back();   
4</script>   

response.end
else
body=rs("body")
emailtitle=rs("emailtitle")
rs.close
set rs=nothing
conn.close
set conn=nothing
end if
end if

1<form action="loadmail.asp" enctype="multipart/form-data" method="post" name="upload_file" onsubmit="return check(this)">
2<table border="0" cellpadding="2" cellspacing="2" width="100%">
3<tr>
4<td width="11%">
5<div align="right">发件人:</div>
6</td>
7<td width="89%">
8<input ```"="" myid")="" name="senderempl" type="hidden" value="```
9=session("/>   

=session("myid")

 1</tr>
 2<tr>
 3<td width="11%">
 4<div align="right">收件人:</div>
 5</td>
 6<td width="89%">
 7<input name="geterempl" size="40" type="text" value="```
 8=geterempl
 9```"/>
10<input name="emaillevel" style="background-color: #FEF7ED" type="checkbox" value="1"/>   
11紧急信件 </td>
12</tr>
13<tr>
14<td valign="top" width="11%"> </td>
15<td width="89%">发送多个人的时候可以使用"<font color="#9999FF">|</font>"隔开,例如:<font color="#3399FF">01234|01235|01236</font>,第一位和最后一位不需要"<font color="#9999FF">|</font>"<br/>
16<font color="#FF0000">新功能</font>:您可以把信信直接发送给您设定的<a href="group.asp">某用户</a>,发送格式为:gr:组序号,例如<font color="#0099FF">gr:001</font></td>
17</tr>
18<tr>
19<td width="11%">
20<div align="right"></div>
21</td>
22<td width="89%">
23<input name="receempl" style="background-color: #FEF7ED" type="checkbox" value="1"/>   
24保存一份到收藏夹[<font color="#3399FF">选定此项,则邮件发送到对方邮箱的同时发送到自己的收藏夹里</font>]</td>
25</tr>
26<tr>
27<td valign="top" width="11%"> </td>
28<td width="89%"> </td>
29</tr>
30<tr>
31<td align="right" width="11%"> 主题:</td>
32<td width="89%">
33<input name="emailtitle" size="60" type="text" value="```
34=emailtitle
35```"/>
36</td>
37</tr>
38<tr>
39<td valign="top" width="11%">
40<div align="right">正文:</div>
41</td>
42<td width="89%">
43<textarea cols="60" name="body" rows="8">```
44=body
45```</textarea>
46</td>
47</tr>
48<tr>
49<td valign="top" width="11%">
50<div align="right">签名:</div>
51</td>
52<td width="89%">
53<textarea cols="30" name="emailshowname" rows="6">```
54=application(session("myid")&amp;amp;"_name")
55```</textarea>
56</td>
57</tr>
58<tr>
59<td width="11%">
60<div align="right">
61<input name="FileUploadStart" type="hidden"/>   
62附件1: </div>
63</td>
64<td width="89%">
65<input name="file_up" size="50" type="file"/>
66</td>
67</tr>
68<tr>
69<td width="11%">
70<div align="right">附件2:</div>
71</td>
72<td width="89%">
73<input name="file_up1" size="50" type="file"/>
74</td>
75</tr>
76<tr>
77<td width="11%">
78<div align="right">附件3:</div>
79</td>
80<td width="89%">
81<input name="file_up2" size="50" type="file"/>
82<input name="FileUploadEnd" type="hidden"/>
83</td>
84</tr>
85<tr>
86<td width="11%">
87<div align="right"></div>
88</td>
89<td width="89%">
90<input type="submit" value="确定"/>
91</td>
92</tr>
93</table>
94</form>
95</body>
96</html>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus