当前位置: 移动技术网 > IT编程>开发语言>其他编程 > 如何用POP3接收电子邮件?

如何用POP3接收电子邮件?

2017年12月08日  | 移动技术网IT编程  | 我要评论

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

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网