如何用POP3接收電子郵件?

來源:互聯網
上載者:User

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

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.