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

  

  

  Chilkat ActiveX Components

  Chilkat .NET Components

  Chilkat C++ Libraries

  

  

  

  

 

FAQ

DOWNLOAD ReferenceASP ExamplesVisual Basic Examples


Chilkat Mail Example
Read Email from a POP3 Server

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

IMPORTANT: If Chilkat Mail and Chilkat WebMail are separate components.
If you are using Chlilkat WebMail, the code is the same, but the names of the components created are different. Use CreateObject("ChilkatWebMail.WebMailMan") instead.

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

<HTML>
<HEAD>
<TITLE>Chilkat Mail 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>

</BODY>
</HTML>

This is the form target (read_mail.asp):

<%@ LANGUAGE="VBSCRIPT" %>

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

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

<%
	' Create a mailman
	set mailman = Server.CreateObject("ChilkatMail.ChilkatMailMan")

	' Get the UnlockCode free from http://www.chilkatsoft.com
	mailman.UnlockComponent "UnlockCode"

	' 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")

	' If you want to limit the number of messages retrieved, set MaxCount
	' For example, this retrieves the first 10 messages in the mailbox:
	' mailman.MaxCount = 10

	' If you want to avoid any messages that are too large, you can set
	' SizeLimit.  For example, this prevents the mailman from trying to
	' download messages bigger than 100,000 bytes.
	' mailman.SizeLimit = 100000

	' 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

	Set mailBundle = Nothing
	Set mailman = Nothing

%>

<BR>DONE.<BR>

</BODY>
</HTML>


 

 


Privacy Statement. Copyright 2000-2008 Chilkat Software, Inc. All rights reserved.
Send feedback to support@chilkatsoft.com

Components for Microsoft Windows XP, 2000, 2003 Server, Vista, and Windows 95/98/NT4.