欢迎光临
我们一直在努力

jmail4.1用pop3收信的例子。

建站超值云服务器,限时71元/月

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

%>

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » jmail4.1用pop3收信的例子。
分享到: 更多 (0)

相关推荐

  • 暂无文章