Sample code for 30+ languages & platforms
Classic ASP

Get the IMAP Server Capabilities

See more IMAP Examples

Demonstrates the Chilkat Imap.Capability method, which sends the IMAP CAPABILITY command and returns the server's raw capability response. This example connects and prints the capability list. Use HasCapability to test for a specific one.

Background: Not all IMAP servers support the same features. The CAPABILITY response is the server's advertised menu — a space-separated list of extensions such as IDLE (push notifications of new mail), MOVE, UIDPLUS, QUOTA, and the supported AUTH= mechanisms. A well-behaved client checks capabilities before relying on an optional feature, falling back gracefully when it is absent.

Chilkat Classic ASP Downloads

Classic ASP
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<%
success = 0

'  Demonstrates the Imap.Capability method, which sends the IMAP CAPABILITY command and
'  returns the server's raw capability response.

set imap = Server.CreateObject("Chilkat.Imap")

imap.Ssl = 1
imap.Port = 993

success = imap.Connect("imap.example.com")
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
    Response.End
End If

'  Ask the server for its capability list.
capabilities = imap.Capability()
If (imap.LastMethodSuccess = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
    Response.End
End If

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

'  Sample output:
'  
'    Server capabilities: * CAPABILITY IMAP4rev1 LOGIN-REFERRALS ID ENABLE IDLE SASL-IR LITERAL+ AUTH=PLAIN AUTH=LOGIN
'    aaab OK Pre-login capabilities listed, post-login capabilities have more.

success = imap.Disconnect()
If (success = 0) Then
    Response.Write "<pre>" & Server.HTMLEncode( imap.LastErrorText) & "</pre>"
    Response.End
End If


%>
</body>
</html>