top
Loading...
jmail4.1用pop3收信的例子
【caoli】 于 2000-12-22 17:24:14 加貼在 Joy ASP ↑:

<% 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: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

%>

北斗有巢氏 有巢氏北斗