<% 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 & " (<a href=""mailto:"& re.email &""">" & re.email & "</a>)" & separator
else
recc = reto & re.name & " (<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:\email\attachments\" & 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
%>
