高分求接收和发送电子邮件的ASP代码

如题,分数可以再加
---------------------------------------------------------------

1   
2dim XingWorld_sign,iemail   
3XingWorld_sign = "

<br/>

<br/>

<br/>

<br/>

<br/>

<font style="font-size:9pt">"&amp;_
"<b>欢迎光临我们的网站! 明日网站,有家的地方……</b><br/>"&amp;_
"---------------------------------------------------------------------------------------------------"&amp;_
"<li type="square">我的网络小屋: 我的相册 / 我的文章 / 短消息 / 留言板 / 小屋计数器……我们全都为您准备好了"&amp;_
"<li type="square">免费留言板:为您提供最酷的自行编写界面的留言板(即将到来)"&amp;_
"<li type="square">源代码基地:为中国程序员提供学习资料"&amp;_
"<li type="square">大量电脑教程:从最简单的怎样操作电脑开始循序渐进一点一点带您进入程序设计的大门"&amp;_
"<li type="square">大量技术文章:内容非常丰富而且所有文章都是经过精挑细选的,以 <b>ASP</b> 文章居多"&amp;_
"<li type="square">编程工具下载:为您准备最需要的编程工具"&amp;_
"<li type="square">商业服务:承接大中型网站建设(包括数据库开发)"&amp;_
"<li type="square">………………"&amp;_
"<li type="square">我们的网址 <font face="verdana">&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;</font> <a href="http://XingWorld.net" target="_blank"><font face="verdana">XingWorld.net</font></a>"

SMTPServer="xingworld.net"
SystemEmail="[email protected]"
topic="test"
mailbody = "aaaaaaaaaaaaaaaaaaaaaaaaaaaaa" &amp; XingWorld_sign
iemail="[email protected]"

' m=cint( Request.QueryString )
' if m="" then m=2
' if m=1 then
' call Jmail(iemail)
' elseif m=2 then

' call Cdonts(iemail)

' elseif m=3
' call aspemail(iemail)
' end if

sub Jmail(email)
Dim JMail,SendMail
Set JMail=Server.CreateObject("JMail.SMTPMail")
JMail.Logging=True
JMail.Charset="gb2312"
JMail.ContentType = "text/html"
JMail.ServerAddress=SMTPServer
JMail.Sender=SystemEmail
JMail.Subject=topic
JMail.Body=mailbody
JMail.AddRecipient email
JMail.Priority=3
JMail.Execute
Set JMail=nothing
if err then
SendMail=err.description
err.clear
else
SendMail="OK"
end if
end sub

sub Cdonts(email)
dim objCDOMail
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.From = SystemEmail
objCDOMail.To = email
objCDOMail.Subject = topic
objCDOMail.BodyFormat = 0
objCDOMail.MailFormat = 0
objCDOMail.Body =mailbody
objCDOMail.Send
if err then
SendMail=err.description
err.clear
else
SendMail="OK"
end if
response.write "<p><font color="#00A000">Success! Message sent to "&amp;email&amp;"</font></p>"
Set objCDOMail = Nothing
end sub

sub aspemail(email)
Set Mail = Server.CreateObject("Persits.MailSender")
' enter valid SMTP host
Mail.Host = SMTPServer

Mail.From = SystemEmail
Mail.FromName = "明日论坛"
Mail.AddAddress email

' message subject
Mail.Subject = topic
' message body
Mail.Body = mailbody
Mail.IsHTML = True

strErr = ""
bSuccess = False
On Error Resume Next '######- catch errors
Mail.Send '######&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt;&gt; send message
If Err &lt;&gt; 0 Then '######- error occurred
strErr = Err.Description
else
bSuccess = True
End If

If strErr &lt;&gt; "" Then
response.write "<p><font color="#FF0000">Error occurred: <i>"&amp;strErr&amp;"</i></font></p>"
response.end
End If

If bSuccess Then
response.write "<p><font color="#00A000">Success! Message sent to "&amp;email&amp;"</font></p>"
session("myemail") = email
End If

end sub
---------------------------------------------------------------

&lt;%
dim username,email
dim mysession,myinbox,mymessages,mymessage
dim messageindex
messageindex=request("messageindex")
if messageindex="" then messageindex=1
temp=messageindex
temp1=messageindex+10

username=session("u_logname")
email=session("u_logname")&amp;session("domain")
set mysession=server.createobject("cdonts.session")'
mysession.logonsmtp username,email
set myinbox=mysession.inbox
set mymessages=myinbox.messages

 1<html>
 2<head>
 3<title>电子邮件</title>
 4<meta content="text/html; charset=utf-8" http-equiv="Content-Type"/>
 5<link href="../css/office.css" rel="stylesheet" type="text/css"/>
 6</head>
 7<body bgcolor="#FFFFFF" text="#000000">
 8<div class="TitleBar">电子邮件列表</div>
 9<div align="center">
10<!-- #BeginLibraryItem "/Library/mail.lbi" -->
11<table align="center" border="0" cellpadding="0" cellspacing="0" width="95%">
12<tr align="center">
13<td width="48%"><a href="send.asp"><img border="0" height="22" src="../icon/newmail2.gif" width="75"/></a></td>
14<td width="52%"><a href="index.asp"><img border="0" height="22" src="../icon/newmail3.gif" width="75"/></a></td>
15</tr>
16</table>
17<hr size="1"/>
18<!-- #EndLibraryItem --><font size="3">   

If mymessages.count=0 then

1你的邮箱中没有邮件   

Else

 1</font><br/>
 2</div>
 3<form action="del.asp" method="post" name="formXW">
 4<table align="center" border="0" cellpadding="0" cellspacing="0" width="85%">
 5<tr>
 6<td width="75%"><font color="#666666" size="2">[收件箱] ```
 7=email
 8```的收件箱</font></td>
 9<td align="right" width="25%"> </td>
10</tr>
11<tr><td colspan="2"><table width="560"><tr><td></td></tr></table></td></tr>
12</table>
13<table align="center" cellpadding="0" cellspacing="0" class="tableframe" width="85%">
14<tr class="listtitle">
15<td class="listcelltitle" height="8"> 当前您的收件箱中邮件数为 ```
16=mymessages.count
17``` </td>
18</tr>
19<tr><td>
20<table border="0" cellpadding="0" cellspacing="0" width="100%">
21<tr align="center" bgcolor="#E6ECF2">
22<td height="4" width="5%"> </td>
23<td height="4" width="8%"><font size="2">优先</font></td>
24<td height="4" width="4%"><font size="2">序号</font></td>
25<td height="4" width="3%"><font size="2"> </font></td>
26<td height="4" width="15%"><font size="2"> 发件人 </font></td>
27<td height="4" width="29%"><font size="2">主题 </font></td>
28<td height="4" width="10%"><font size="2">附件 </font></td>
29<td height="4" width="15%"><font size="2">日期 </font></td>
30<td height="4" width="11%"><font size="2">字节</font></td>
31</tr>
32<tr align="center" bgcolor="#666666">
33<td colspan="9" height="1"><spacer type="block" width="1"/></td>
34</tr>   

'得到当前的邮件发送程序在服务器上路径
TempURL = Request.ServerVariables("Path_Translated")
getURL = Left(TempURL,InStrRev(TempURL,""))
'在当前路径下建立一个与当前用户同名的目录用于存放用户的附件
Set FSO = CreateObject("Scripting.FileSystemObject")
If Not (FSO.FolderExists(getURL&amp;username)) Then FSO.CreateFolder(getURL&amp;username)
'遍寻邮件
for i=messageindex to mymessages.count
set mymessage=mymessages.item(messageindex)
'对每一封邮件建立附件对象
set objMessage = mymessages.Item(i)
set colAttachments = objMessage.Attachments
'邮件的优先级
if mymessage.importance=0 then tempimportance="普通"
if mymessage.importance=1 then tempimportance="比较重要"
if mymessage.importance=2 then tempimportance="非常重要"

 1<tr align="center" class="listrow1">
 2<td class="listcellrow" width="5%"><font size="2"><img height="16" src="../icon/emailopen.gif" width="16"/></font></td>
 3<td class="listcellrow" width="8%"><font size="2">```
 4=tempimportance
 5```</font></td>
 6<td class="listcellrow" width="4%"><font size="2">```
 7=i
 8```</font></td>
 9<td class="listcellrow" width="3%"> <font size="2">
10<input =messageindex="" ```="" name="chbox" type="checkbox" value="```"/>
11</font></td>
12<td class="listcellrow" width="15%"><a =messageindex="" ```="" href="view.asp?messageindex=```"><font size="2">```
13=mymessage.sender
14```</font></a></td>
15<td align="left" class="listcellrow" width="29%">
16<div align="center"><font size="2">```
17=mymessage.subject
18``` </font></div>
19</td>   
20&lt;%   
21'得到附件的名称   
22AttachName = colAttachments.Item(1).Name   
23realAttachName = Right(AttachName,(len(AttachName)-InStrRev(AttachName,"\")))</tr></table></td></tr></table></form></body></html></li></li></li></li></li></li></li></li></li></font>
Published At
Categories with Web编程
Tagged with
comments powered by Disqus