当前位置: 代码网 > it编程>编程语言>其他编程 > 如何用POP3接收电子邮件?

如何用POP3接收电子邮件?

2024年05月18日 其他编程 我要评论
<% set pop3 = server.createobject( "jmail.pop3" ) pop3.connect "username", "password", "pop3mail.

<%  set pop3 = server.createobject( "jmail.pop3" )

  pop3.connect "username", "password", "pop3mail.intels.net"
  ' pop3
的连接用户名,密码,pop3地址.

  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:\intels\email\attachments\" & at.filename )
            getattachments = getattachments & "<a href=""/intels/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>
发件人:李雁冰@163.net</td>
            <td><%= msg.fromname %></td>
          </tr>
          <tr>
            <td>
收件人:宋颜浩@163.net</td>
            <td><%= reto %></td>
          </tr>
          <tr>
            <td>
抄送:申朝阳@163.net</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
%>

[1]

(0)

相关文章:

版权声明:本文内容由互联网用户贡献,该文观点仅代表作者本人。本站仅提供信息存储服务,不拥有所有权,不承担相关法律责任。 如发现本站有涉嫌抄袭侵权/违法违规的内容, 请发送邮件至 2386932994@qq.com 举报,一经查实将立刻删除。

发表评论

验证码:
Copyright © 2017-2025  代码网 保留所有权利. 粤ICP备2024248653号
站长QQ:2386932994 | 联系邮箱:2386932994@qq.com