jmail4.1用pop3收信的例子

1 Set pop3 = Server.CreateObject( "JMail.POP3" )   
2  
3'pop3的连接用户名,密码,pop3地址   
4pop3.Connect "username", "password", "mail.mydomain.com"   
5  
6Response.Write( "你有" & pop3.count & " 封邮件。

<br/>

<br/>

 1" )   
 2  
 3if pop3.count > 0 then   
 4Set msg = pop3.Messages.item(1)   
 5ReTo = ""   
 6ReCC = ""   
 7  
 8Set Recipients = msg.Recipients   
 9separator = ", "   
10  
11' 现在得到所有的收件人,并且存储   
12  
13For i = 0 To Recipients.Count - 1   
14If i = Recipients.Count - 1 Then   
15separator = ""   
16End If   
17  
18Set re = Recipients.item(i)   
19If re.ReType = 0 Then   
20ReTo = ReTo & re.Name & " (

<a &"""="" href="" mailto:"&="" re.email="">" &amp; re.EMail &amp; "</a>

1)" &   
2separator   
3else   
4ReCC = ReTo & re.Name & " (

<a &"""="" href="" mailto:"&="" re.email="">" &amp; re.EMail &amp; "</a>

 1)" &   
 2separator   
 3End If   
 4Next   
 5  
 6'这个程序得到附件,并且保存到服务器的硬盘上。也可以返回附件的详细连接   
 7Function getAttachments()   
 8Set Attachments = msg.Attachments   
 9separator = ", "   
10  
11For i = 0 To Attachments.Count - 1   
12If i = Attachments.Count - 1 Then   
13separator = ""   
14End If   
15  
16Set at = Attachments(i)   
17at.SaveToFile( "c:\EMail\attachments\" & at.Filename )   
18getAttachments = getAttachments & "

<a "="" &="" &"""="" at.filename="" attachments="" email="" href="">" &amp;_
at.FileName &amp; "(" &amp; at.Size &amp; " bytes)" &amp; "</a>

1" & separator   
2Next   
3End Function   
4  
 1<html>
 2<body>
 3<table>
 4<tr>
 5<td>邮件标题</td>
 6<td>```
 7= msg.Subject 
 8```</td>
 9</tr>
10<tr>
11<td>发件人</td>
12<td>```
13= msg.FromName 
14```</td>
15</tr>
16<tr>
17<td>收件人</td>
18<td>```
19= ReTO 
20```</td>
21</tr>
22<tr>
23<td>抄送</td>
24<td>```
25= ReCC 
26```</td>
27</tr>
28<tr>
29<td>附件</td>
30<td>```
31= getAttachments 
32```</td>
33</tr>
34<tr>
35<td>内容</td>
36<td><pre>```
37= msg.Body 
38```</pre></td>
39</tr>
40</table>
41</body>
42</html>
1 end if   
2  
3pop3.Disconnect   
4  
Published At
Categories with Web编程
Tagged with
comments powered by Disqus