·您的位置: 首页 » 资源教程 » 编程开发 » ASP » JMAIL4.1用POP3收信的例子

JMAIL4.1用POP3收信的例子

类别: ASP教程  评论数:0 总得分:0
<% Set pop3 = Server.CreateObject( "JMail.POP3" )

\'pop3的连接用户名,密码,pop3地址
pop3.Connect "username", "password", "mail.mydomain.com"

Response.Write( "你有" & pop3.count & " 封邮件。<br><br>" )

if pop3.count > 0 then
Set msg = pop3.Messages.item(1)
ReTo = ""
ReCC = ""

Set Recipients = msg.Recipients
separator = ", "

\' 现在得到所有的收件人,并且存储

For i = 0 To Recipients.Count - 1
If i = Recipients.Count - 1 Then
separator = ""
End If

Set re = Recipients.item(i)
If re.ReType = 0 Then
ReTo = ReTo & re.Name & "&nbsp;(<a href=""mailto:"& re.EMail &""">" & re.EMail & "</a>)" & separator
else
ReCC = ReTo & re.Name & "&nbsp;(<a href=""mailto:"& re.EMail &""">" & re.EMail & "</a>)" & separator
End If
Next

\'这个程序得到附件,并且保存到服务器的硬盘上。也可以返回附件的详细连接
Function getAttachments()
Set Attachments = msg.Attachments
separator = ", "

For i = 0 To Attachments.Count - 1
If i = Attachments.Count - 1 Then
separator = ""
End If

Set at = Attachments(i)
at.SaveToFile( "c:EMailattachments" & at.Filename )
getAttachments = getAttachments & "<a href=""/EMail/attachments/" & at.Filename &""">" &_
at.FileName & "(" & at.Size & " bytes)" & "</a>" & separator
Next
End Function

%>
<html>
<body>
<TABLE>
<tr>
<td>邮件标题</td>
<td><%= msg.Subject %></td>
</tr>
<tr>
<td>发件人</td>
<td><%= msg.FromName %></td>
</tr>
<tr>
<td>收件人</td>
<td><%= ReTO %></td>
</tr>
<tr>
<td>抄送</td>
<td><%= ReCC %></td>
</tr>
<tr>
<td>附件</td>
<td><%= getAttachments %></td>
</tr>
<tr>
<td>内容</td>
<td><pre><%= msg.Body %></pre></td>
</tr>
</TABLE>
</body>
</html>

<% end if

pop3.Disconnect

%>
-= 资 源 教 程 =-
文 章 搜 索
关键词:
类型:
范围:
纯粹空间 softpure.com
Copyright © 2006-2008 暖阳制作 版权所有
QQ: 15242663 (拒绝闲聊)  Email: faisun@sina.com
 纯粹空间 - 韩国酷站|酷站欣赏|教程大全|资源下载|免费博客|美女壁纸|设计素材|技术论坛   Valid XHTML 1.0 Transitional
百度搜索 谷歌搜索 Alexa搜索 | 粤ICP备19116064号-1