Zip Component, Email Component, Encryption Component ActiveX Control for Zip Compression .NET Components for ASP.NET
ActiveX and .NET Components for Zip Compression, Encryption, Email, XML, S/MIME, HTML Email, Character Encoding, Digital Certificates, FTP, and more ASP Email ActiveX Component

  

  

  

  

  

 

ASP Email Component

DOWNLOAD ReferenceASP Examples


WebMail ASP Example

ASP Script to Read Email from a POP3 Server

This example shows how to read Email from a POP3 server.

First, get the hostname of the POP3 mail server, and login information using this HTML form:

<HTML>
<HEAD>
<TITLE>Chilkat WebMail Example: Read Mail Form</TITLE>
</HEAD>
<BODY>

<form method="post" action="read_mail.asp">
  <table width="75%" border="0">
    <tr> 
      <td width="42%" nowrap> 
        <div align="right">POP3 Hostname</div>
      </td>
      <td width="58%"> 
        <input type="text" name="popHostname" size="40">
      </td>
    </tr>
    <tr> 
      <td width="42%" nowrap> 
        <div align="right">Login</div>
      </td>
      <td width="58%"> 
        <input type="text" name="loginName" size="40">
      </td>
    </tr>
    <tr> 
      <td width="42%" nowrap> 
        <div align="right">Password</div>
      </td>
      <td width="58%"> 
        <input type="text" name="password" size="40">
      </td>
    </tr>
  </table>
  <p>
<input type="submit" value="Submit">
  </p>
</form>
<!-- End of ASP Form for Reading Mail -->
</BODY>
</HTML>

This is the HTML form target (read_mail.asp):

<%@ LANGUAGE="VBSCRIPT" %>

<HTML>
<HEAD>
<TITLE>Chilkat ASP Mail Example: Read a POP3 Mailbox</TITLE>
</HEAD>
<BODY>

Reading email....<br><br>

<%
	' Create a mailman
	set mailman = Server.CreateObject("ChilkatWebMail.WebMailMan")

    ' Unlock the component - use your trial or purchased unlock code.
    mailman.UnlockComponent "unlock_code"

	' Tell the mailman where to get mail, and the login/password
	mailman.MailHost = Request.Form("popHostname")
	mailman.PopUsername = Request.Form("loginName")
	mailman.PopPassword = Request.Form("password")

	' Copy the mail without removing it from the server.
	' When reading email, the mailman always returns a MailBundle
	Set mailBundle = mailman.CopyMail
	  ' To Remove the mail from the server, use TransferMail:
	  ' Set mailBundle = mailman.TransferMail

	If Not (mailBundle Is Nothing) Then

	  ' Loop over the email messages in the bundle
	  For i = 0 To mailBundle.messageCount - 1

		Set email = mailBundle.GetEmail(i)

		Response.write "<br>" & i & "<br>"
		Response.write "<b>From:</b> " & Server.HTMLEncode(email.From) & "<br>"
		Response.write "<b>Subject:</b> " & Server.HTMLEncode(email.Subject) & "<br>"
		
		if email.NumTo = 0 then
			Response.write "<b>To:</b> " & Server.HTMLEncode(email.GetTo(0)) & "<br>"
		else
			Response.write "<b>To:</b><blockquote>"
			For j = 0 to email.NumTo
				Response.write Server.HTMLEncode(email.GetTo(j)) & "<br>"
			Next
			Response.write "</blockquote><br>"
		end if

		'Response.write "<b>Raw Header:</b><br><pre>"
		'Response.write Server.HTMLEncode(email.RawHeader)
		'Response.write "</pre><br>"
		Set email = Nothing
	  Next

	End If
%>
    <br>(View page source to see the log)
    <XML ID="XMLID">
<%
    Response.write mailman.GetInstanceLog()
%>
    </XML>
<%

	Set mailBundle = Nothing

	' Standard ASP cleanup of objects
	Set mailman = Nothing

%>

<BR>DONE.<BR>

</BODY>
</HTML>


* This is an Active Server Pages (ASP) example script showing how to read mail from a POP3 server.

 


Privacy Statement. Copyright 2000-2012 Chilkat Software, Inc. All rights reserved.

(Regarding the usage of the Android logo) Portions of this page are reproduced from work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Send feedback to support@chilkatsoft.com


Software components and libraries for Linux, MAC OS X, IOS (IPhone), Android™, Solaris, RHEL/CentOS
Microsoft Windows 7, Vista, XP, 2000, 2003 Server, 2008 Server, and Windows 95/98/NT4.