Homepageseo.com
Login
登录[Login]
Reg
注册[Reg]
Member
会员[Member]
BBs
论坛[BBs]
logout
退出[Logout]
Search
搜索[Search]
Search For:        Advanced Search   
Guide: 首页 >> IT技术专栏 >> 建站技术 >> jmail4.1用pop3收信的例子

jmail4.1用pop3收信的例子

作者: 11830 来源: 互联网 日期: 2008-07-25,06:27

jmail4.1用pop3收信的例子

<%  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:\EMail\attachments\" & at.Filename )
            getAttachments = getAttachments & "<a href="http://www.chinaitpower.com/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

%>

责任编辑: admin 参与评论
免责申明: 本网转载内容均来自互联网,本网并不保证其内容的真实性。如果您认为本网站某部分的内容有侵权嫌疑,敬请立即通知我们,我们将在第一时间予以更改或删除。
Copyright © 2006 HomepageSeo.com ®. All rights reserved. Website development by 八桂网络科技 Author:Homepage 桂ICP备06012988号