ASP Examples

ChilkatHOMEASPVisual BasicVB.NETC#Visual C++CMFCDelphiFoxProJavaPerlPHPPythonRubySQL ServerVBScript

ASP Examples

ASP String
ASP Byte Array
Bounced Mail
Bz2
Character Encoding
CSV
Digital Certificates
Digital Signatures
Email
FTP
HTML-to-XML
HTTP
IMAP
Encryption
MHT / HTML Email
POP3
RSA
S/MIME
SMTP
Socket
Spider
SSH
SSH Tunnel
SSH Key
SFTP
Tar
ASP Upload
XML
XMP
Zip Compression

More Examples...
Email Object
DKIM / DomainKey
NTLM
DH Key Exchange
DSA
FileAccess
RSS
Atom
Self-Extractor
Service
PPMD
Deflate
Bzip2
LZW

 

 

 

 

 

 

Fetch Oldest/Newest IMAP Email

Emails may be downloaded by sequence number. Assuming the selected mailbox is not empty, the oldest email is at sequence number 1, and the newest email is at sequence number N. The FetchSingle method may be used to download by sequence number.

Download Chilkat IMAP ActiveX

<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
set imap = Server.CreateObject("Chilkat.Imap")

'  Anything unlocks the component and begins a fully-functional 30-day trial.
success = imap.UnlockComponent("Anything for 30-day trial")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode(imap.LastErrorText) & "</pre>"

End If

'  Connect to an IMAP server.
success = imap.Connect("mail.testemail.net")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode(imap.LastErrorText) & "</pre>"

End If

'  Login
success = imap.Login("***","***")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode(imap.LastErrorText) & "</pre>"

End If

'  Select an IMAP mailbox
success = imap.SelectMailbox("Inbox")
If (success <> 1) Then
    Response.Write "<pre>" & Server.HTMLEncode(imap.LastErrorText) & "</pre>"

End If

'  After selecting a mailbox, the NumMessages property
'  contains the number of emails in the selected mailbox.

n = imap.NumMessages

If (n > 0) Then

    '  The oldest email is always at sequence number 1.
    isUid = 0

    ' oldestEmail is a Chilkat.Email2
    Set oldestEmail = imap.FetchSingle(1,isUid)
    If (Not (oldestEmail Is Nothing )) Then

        '  Display the From and Subject
        Response.Write "<pre>" & Server.HTMLEncode( oldestEmail.FromAddress) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( oldestEmail.Subject) & "</pre>"

        Response.Write "<pre>" & Server.HTMLEncode( "--") & "</pre>"

    End If

    '  The newest email is at sequence number N:

    ' newestEmail is a Chilkat.Email2
    Set newestEmail = imap.FetchSingle(n,isUid)
    If (Not (newestEmail Is Nothing )) Then

        '  Display the From and Subject
        Response.Write "<pre>" & Server.HTMLEncode( newestEmail.FromAddress) & "</pre>"
        Response.Write "<pre>" & Server.HTMLEncode( newestEmail.Subject) & "</pre>"

    End If

End If

'  Disconnect from the IMAP server.
imap.Disconnect 
%>
</body>
</html>

 

Need a specific example? Send a request to support@chilkatsoft.com

© 2000-2010 Chilkat Software, Inc. All Rights Reserved.