Imap DataFlex Reference Documentation

Imap

Current Version: 11.5.0

Chilkat.Imap

Access, search, download, organize, and monitor email on IMAP servers.

Chilkat.Imap is a full-featured IMAP client class for applications that need reliable server-side email access and mailbox management. It supports secure connections, authentication, mailbox selection, message searching, downloading email and attachments, flag management, moving and copying messages, appending MIME, IDLE-based change monitoring, and detailed diagnostics for troubleshooting server behavior.

Secure IMAP connections

Connect with SSL/TLS, STARTTLS, OAuth2, password authentication, proxy settings, timeouts, and connection diagnostics.

Mailbox selection and listing

List mailboxes, select folders, inspect mailbox state, and work with server-side folders such as Inbox, Sent, Archive, or custom folders.

Search and fetch messages

Search by IMAP criteria, work with UIDs or sequence numbers, download full messages, headers, MIME, body text, or selected message parts.

Message management

Set and clear flags, mark messages read or unread, copy or move messages, delete messages, expunge mailboxes, and append MIME to folders.

Attachments and MIME

Retrieve email as Chilkat Email objects, process MIME content, and save or inspect attachments as needed.

IDLE and diagnostics

Monitor mailbox changes with IMAP IDLE and use detailed logging, response text, and LastErrorText to troubleshoot servers.

Common pattern: Connect securely, authenticate, select a mailbox, search or fetch messages using UIDs when possible, perform message or folder operations, then disconnect cleanly. Use detailed diagnostics when working with provider- specific IMAP behavior.

Object Creation

// (Dataflex programs use the 32-bit Chilkat ActiveX)
Handle hoImap
Get Create(RefClass(cComChilkatImap)) to hoImap

Properties

AbortCurrent
Function ComAbortCurrent Returns Boolean
Procedure Set ComAbortCurrent Boolean value
Introduced in version 9.5.0.58

Controls cancellation of the method currently running on this Imap object.

  • Set this property to True to request that a long-running network operation abort.
  • Short methods that do not perform lengthy processing or network communication are generally unaffected.
  • Both synchronous and asynchronous calls can be aborted. A synchronous call may be canceled by setting this property from another thread.

The property is automatically reset to False when the abort is processed. If no method is running, it is reset when the next method begins.

Canceling an operation can leave the connection in an uncertain state. Close the connection, reconnect, authenticate again, and reselect the mailbox before continuing. Output objects may contain partial results, and a server-side operation may already have been partially applied before cancellation.

top
AppendSeen
Function ComAppendSeen Returns Boolean
Procedure Set ComAppendSeen Boolean value

Controls the initial \Seen flag for these methods:

  • True (the default): the appended message is marked as seen.
  • False: the appended message is initially unseen.

The flag-specific append methods use their explicit arguments and do not use this property.

top
AppendUid
Function ComAppendUid Returns Integer

Contains the UID assigned by the server to the message most recently appended successfully.

The default is 0. After any successful append, this property is set to the UID reported by the server, or to 0 if the server succeeds but does not report an appended UID. A failed append leaves the previous value unchanged.

top
AuthMethod
Function ComAuthMethod Returns String
Procedure Set ComAuthMethod String value

Selects the IMAP authentication mechanism. Matching is case-insensitive, but spelling matters.

ValuePurpose
LOGINUsername and password authentication.
PLAINSASL PLAIN authentication. AuthzId may also be used.
CRAM-MD5Challenge-response authentication when supported by the server.
NTLMWindows Integrated Authentication.
XOAUTH2OAuth 2.0 access-token authentication.

The default is LOGIN, and an empty or unrecognized value also uses the LOGIN method. If the selected mechanism fails or is not supported by the server, Chilkat does not fall back to another authentication method.

If NTLM authentication fails because of an NTLM-version compatibility issue, set Global.DefaultNtlmVersion to 1 and retry.

top
AuthzId
Function ComAuthzId Returns String
Procedure Set ComAuthzId String value

Specifies the optional authorization identity used with the PLAIN authentication mechanism.

Leave this property empty unless the IMAP server requires an authorization identity that differs from the login identity supplied to Login.

top
AutoDownloadAttachments
Function ComAutoDownloadAttachments Returns Boolean
Procedure Set ComAutoDownloadAttachments Boolean value

Controls whether methods that download a complete email also download ordinary attachment bodies. The default is True.

  • True: complete-email fetches include attachment bodies.
  • False: complete-email fetches omit ordinary attachment bodies, whether the result is returned as an Email object or as MIME.

Header-only methods never download attachment bodies. They add ckx-imap-* metadata describing the attachments, which can be read with GetMailNumAttach, GetMailAttachFilename, and GetMailAttachSize. In this state, the Email object's ordinary attachment count can still be 0.

Related MIME parts used by an HTML body are not treated as ordinary attachments. Signed or encrypted messages are always downloaded in full because their complete MIME is required for verification or decryption.

top
AutoFix
Function ComAutoFix Returns Boolean
Procedure Set ComAutoFix Boolean value

When True (the default), changes the public Ssl and StartTls property values when Connect is called for a standard IMAP port:

  • Port 993: sets Ssl to True and StartTls to False for implicit TLS.
  • Port 143: sets Ssl to False. The existing StartTls value determines whether the connection is upgraded explicitly.

For a nonstandard port, this property makes no changes. Set it to False when the application must preserve an unusual port and TLS combination exactly as configured.

top
ClientIpAddress
Function ComClientIpAddress Returns String
Procedure Set ComClientIpAddress String value

Specifies the local IP address to bind when the computer has multiple network interfaces or addresses.

Leave this property empty for the usual case. The operating system will select the default local interface. When set, use a numeric IP address such as 165.164.55.124, not a hostname.

More Information and Examples
top
ConnectedToHost
Function ComConnectedToHost Returns String

Contains the hostname or IP address of the IMAP server to which the object is currently connected.

Returns an empty string when no connection is active.

top
ConnectTimeout
Function ComConnectTimeout Returns Integer
Procedure Set ComConnectTimeout Integer value

The maximum number of seconds to wait while establishing the TCP connection to the IMAP server.

The default is 30 seconds. This timeout applies to connection establishment, not to later reads from the server.

top
DebugLogFilePath
Function ComDebugLogFilePath Returns String
Procedure Set ComDebugLogFilePath String value

If set to a file path, this property logs the LastErrorText of each Chilkat method or property call to the specified file. This logging helps identify the context and history of Chilkat calls leading up to any crash or hang, aiding in debugging.

Enabling the VerboseLogging property provides more detailed information. This property is mainly used for debugging rare instances where a Chilkat method call causes a hang or crash, which should generally not happen.

Possible causes of hangs include:

  • A timeout property set to 0, indicating an infinite timeout.
  • A hang occurring within an event callback in the application code.
  • An internal bug in the Chilkat code causing the hang.

More Information and Examples
top
Domain
Function ComDomain Returns String
Procedure Set ComDomain String value

Specifies the Windows domain used for NTLM authentication.

This property is optional and may be left empty when the login name already identifies the domain or when NTLM is not used.

top
EnableSecrets
Function ComEnableSecrets Returns Boolean
Procedure Set ComEnableSecrets Boolean value
Introduced in version 11.5.0

Enables automatic resolution of credential values from secure operating-system storage. The default is False.

When True, supported password arguments and properties may contain a secret specification beginning with !! instead of a literal secret. Chilkat resolves the value from Windows Credential Manager or Apple Keychain.

!![appName|]service[|domain]|username

This applies to HttpProxyPassword, SocksPassword, the password supplied to Login, and the password supplied to SshAuthenticatePw.

More Information and Examples
top
HighestModSeq
Function ComHighestModSeq Returns String
Introduced in version 9.5.0.87

Contains the HIGHESTMODSEQ value of the currently selected mailbox as a decimal string.

The value is 0 when no mailbox is selected or the server does not provide this information. A string is used because the value may exceed the integer range of some programming languages.

top
HttpProxyAuthMethod
Function ComHttpProxyAuthMethod Returns String
Procedure Set ComHttpProxyAuthMethod String value

Specifies the authentication mechanism used by an HTTP proxy.

Valid values are Basic and NTLM. This property is used only when HttpProxyHostname identifies an HTTP proxy that requires authentication.

top
HttpProxyDomain
Function ComHttpProxyDomain Returns String
Procedure Set ComHttpProxyDomain String value

Specifies the optional Windows domain for HTTP-proxy NTLM authentication.

It is ignored when the proxy does not use NTLM authentication.

top
HttpProxyHostname
Function ComHttpProxyHostname Returns String
Procedure Set ComHttpProxyHostname String value

Specifies the hostname or numeric IPv4 address of an HTTP proxy through which the IMAP connection is established.

Leave this property empty to connect directly or to use another configured transport such as SOCKS or SSH tunneling.

top
HttpProxyPassword
Function ComHttpProxyPassword Returns String
Procedure Set ComHttpProxyPassword String value

Specifies the password used to authenticate with the configured HTTP proxy.

It is used only when the proxy requires authentication.

top
HttpProxyPort
Function ComHttpProxyPort Returns Integer
Procedure Set ComHttpProxyPort Integer value

Specifies the TCP port of the configured HTTP proxy.

Common values include 8080 and 3128, but the correct value is determined by the proxy server configuration.

top
HttpProxyUsername
Function ComHttpProxyUsername Returns String
Procedure Set ComHttpProxyUsername String value

Specifies the username used to authenticate with the configured HTTP proxy.

It is used only when the proxy requires authentication.

top
KeepSessionLog
Function ComKeepSessionLog Returns Boolean
Procedure Set ComKeepSessionLog Boolean value

Enables or disables the in-memory IMAP protocol log. The default is False.

When enabled, SessionLog contains the raw commands sent to the server and the raw responses received. Use ClearSessionLog to reset it.

More Information and Examples
top
LastAppendedMime
Function ComLastAppendedMime Returns String

Contains the MIME source sent by the most recent successful call to one of the following methods:

A failed append leaves the previous value unchanged. Therefore, read this property only after confirming that the append method succeeded.

top
LastBinaryResult
Function ComLastBinaryResult Returns Variant

This property is mainly used in SQL Server stored procedures to retrieve binary data from the last method call that returned binary data. It is only accessible if Chilkat.Global.KeepBinaryResult is set to True. This feature allows for the retrieval of large varbinary results in an SQL Server environment, which has restrictions on returning large data via method calls, though temp tables can handle binary properties.

top
LastCommand
Function ComLastCommand Returns String

Contains the most recent raw IMAP command sent to the server.

This property is primarily intended for diagnostics when an IMAP operation fails or produces an unexpected response.

top
LastErrorHtml
Function ComLastErrorHtml Returns String

Provides HTML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorText
Function ComLastErrorText Returns String

Provides plain text information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastErrorXml
Function ComLastErrorXml Returns String

Provides XML-formatted information about the last called method or property. If a method call fails or behaves unexpectedly, check this property for details. Note that information is available regardless of the method call's success.

top
LastIntermediateResponse
Function ComLastIntermediateResponse Returns String

Contains the most recent intermediate response received from the IMAP server while a command was in progress.

Use it for protocol-level diagnostics when a command involves continuations or multiple response stages.

top
LastMethodSuccess
Function ComLastMethodSuccess Returns Boolean
Procedure Set ComLastMethodSuccess Boolean value

Indicates the success or failure of the most recent method call: True means success, False means failure. This property remains unchanged by property setters or getters. This method is present to address challenges in checking for null or Nothing returns in certain programming languages. Note: This property does not apply to methods that return integer values or to boolean-returning methods where the boolean does not indicate success or failure.

top
LastResponse
Function ComLastResponse Returns String

Contains the raw response most recently received from the IMAP server.

This property is cleared when Chilkat sends a new command. If a method fails during local argument validation or before a command is sent, the previous response can remain here. Also, a method can return failure even when the last tagged server response is OK, such as when a syntactically successful FETCH returns no matching message. Use the method return value or LastMethodSuccess as the authoritative success indicator.

More Information and Examples
top
LastResponseCode
Function ComLastResponseCode Returns String
Introduced in version 9.5.0.44

Contains the optional IMAP response code from the most recent server response, such as NONEXISTENT or AUTHENTICATIONFAILED. Response-code strings vary by server.

If a method fails before sending an IMAP command, this property can still contain the response code from an earlier command. Use the method return value or LastMethodSuccess to determine whether the current operation succeeded.

More Information and Examples
top
LastStringResult
Function ComLastStringResult Returns String

In SQL Server stored procedures, this property holds the string return value of the most recent method call that returns a string. It is accessible only when Chilkat.Global.KeepStringResult is set to TRUE. SQL Server has limitations on string lengths returned from methods and properties, but temp tables can be used to access large strings.

top
LastStringResultLen
Function ComLastStringResultLen Returns Integer

The length, in characters, of the string contained in the LastStringResult property.

top
LoggedInUser
Function ComLoggedInUser Returns String

Contains the username of the authenticated IMAP session.

Returns an empty string when the object is not logged in.

top
NumMessages
Function ComNumMessages Returns Integer

Contains the number of messages reported when the current mailbox was selected.

The value is updated by SelectMailbox and ExamineMailbox. Unsolicited EXISTS notifications returned by IdleCheck do not automatically update this property; use the notification value or reselect/query the mailbox when a refreshed count is needed.

top
PeekMode
Function ComPeekMode Returns Boolean
Procedure Set ComPeekMode Boolean value

Controls whether fetching full message content marks the message as seen.

  • False (the default): fetching a full message or its raw MIME may set the \Seen flag.
  • True: full message data and raw MIME are fetched without setting \Seen, using IMAP peek semantics.

Fetching headers only does not set \Seen, regardless of this property.

top
Port
Function ComPort Returns Integer
Procedure Set ComPort Integer value

Specifies the IMAP server port. The default is 143.

  • 993 is the standard port for implicit TLS and is normally used with Ssl set to True.
  • 143 is the standard port for ordinary IMAP and for explicit TLS requested with StartTls.

When AutoFix is enabled, standard port values are used to adjust the effective TLS configuration when connecting.

top
PreferIpv6
Function ComPreferIpv6 Returns Boolean
Procedure Set ComPreferIpv6 Boolean value

Controls address-family preference when a hostname resolves to both IPv4 and IPv6 addresses.

  • False (the default): prefer IPv4.
  • True: prefer IPv6.

The other address family may still be used when the preferred one is unavailable.

top
ReadTimeout
Function ComReadTimeout Returns Integer
Procedure Set ComReadTimeout Integer value

The maximum number of seconds that an incoming IMAP response may stall with no additional bytes received.

The default is 60 seconds. This is an inactivity timeout, not a limit on the total time allowed for a large response.

top
RequireSslCertVerify
Function ComRequireSslCertVerify Returns Boolean
Procedure Set ComRequireSslCertVerify Boolean value

Controls verification of the IMAP server's TLS certificate chain.

  • False (the default): a connection is not rejected solely because normal certificate-chain verification fails.
  • True: the connection fails when the certificate is expired, is not yet valid, its signature is invalid, or its chain cannot be verified to a trusted root.

Certificate-chain verification is separate from hostname matching and public-key pinning. Hostname matching, when required, is enforced independently even when this property is False. TlsPinSet supplements rather than replaces normal certificate verification.

The hostname used for the TLS connection is also used for Server Name Indication (SNI) and certificate hostname comparison.

top
SearchCharset
Function ComSearchCharset Returns String
Procedure Set ComSearchCharset String value

Specifies the IMAP CHARSET used by Search, QueryMbx, and QueryThread when search criteria contain non-ASCII characters. The default is UTF-8.

If the criteria contain only 7-bit ASCII characters, no CHARSET is needed and this property has no effect. The value AUTO enables the legacy behavior of selecting a charset by examining the criteria text.

Most applications should leave this property unchanged unless a particular server rejects non-English search text.

top
SelectedMailbox
Function ComSelectedMailbox Returns String

Contains the name of the currently selected or examined mailbox.

Returns an empty string when no mailbox is selected.

top
SendBufferSize
Function ComSendBufferSize Returns Integer
Procedure Set ComSendBufferSize Integer value

Specifies the application-level buffer size used when sending data through the underlying TCP connection.

The default is 32767 bytes. Most applications should leave this setting unchanged.

top
SeparatorChar
Function ComSeparatorChar Returns String
Procedure Set ComSeparatorChar String value

Contains the mailbox-hierarchy delimiter reported by the IMAP server, typically / or ..

MbxList and the legacy mailbox-listing methods update this property from the server's LIST response. The value is a string containing one character.

top
SessionLog
Function ComSessionLog Returns String

Contains the in-memory log of raw IMAP commands and server responses.

KeepSessionLog must be True for logging to occur. Call ClearSessionLog to remove previously collected entries.

Chilkat redacts sensitive credentials, including passwords and OAuth access tokens, from session logs, diagnostic logs, and LastErrorText.

More Information and Examples
top
SocksHostname
Function ComSocksHostname Returns String
Procedure Set ComSocksHostname String value

Specifies the hostname or numeric IP address of the SOCKS proxy.

This property is used only when SocksVersion is 4 or 5.

top
SocksPassword
Function ComSocksPassword Returns String
Procedure Set ComSocksPassword String value

Specifies the SOCKS5 proxy password.

It is ignored for SOCKS4 because SOCKS4 does not define password authentication.

top
SocksPort
Function ComSocksPort Returns Integer
Procedure Set ComSocksPort Integer value

Specifies the SOCKS proxy port. The default is 1080.

This property is used only when SocksVersion is 4 or 5.

top
SocksUsername
Function ComSocksUsername Returns String
Procedure Set ComSocksUsername String value

Specifies the username sent to a SOCKS4 or SOCKS5 proxy.

This property is used only when SocksVersion is 4 or 5.

top
SocksVersion
Function ComSocksVersion Returns Integer
Procedure Set ComSocksVersion Integer value

Selects whether the IMAP connection uses a SOCKS proxy.

ValueBehavior
0Do not use a SOCKS proxy. This is the default.
4Connect through a SOCKS4 proxy.
5Connect through a SOCKS5 proxy.

top
SoRcvBuf
Function ComSoRcvBuf Returns Integer
Procedure Set ComSoRcvBuf Integer value

Sets the operating system's TCP receive-buffer size. The default is 4194304 bytes.

Most applications should leave this unchanged. Increasing it may improve download throughput on high-latency or high-bandwidth networks. Values that are multiples of 4096 are recommended.

top
SortCriteria
Function ComSortCriteria Returns String
Procedure Set ComSortCriteria String value
Introduced in version 11.0.0

Specifies the sort order used by QueryMbx. The default is the empty string, which uses an ordinary IMAP SEARCH.

Set this property to a space-separated list of sort keys. Sorting is ascending unless REVERSE precedes a key. Supported keys are ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, and TO.

Examples:

  • SUBJECT REVERSE DATE
  • REVERSE SIZE
  • ARRIVAL

If the server does not support the IMAP SORT extension, Chilkat automatically falls back to an ordinary SEARCH.

top
SoSndBuf
Function ComSoSndBuf Returns Integer
Procedure Set ComSoSndBuf Integer value

Sets the operating system's TCP send-buffer size. The default is 262144 bytes.

Most applications should leave this unchanged. Increasing it may improve upload throughput; values such as 524288 or 1048576 may be tested when needed.

top
Ssl
Function ComSsl Returns Boolean
Procedure Set ComSsl Boolean value

Controls implicit TLS for the IMAP connection. The default is False.

  • True: begin the connection with a TLS handshake, typically on port 993.
  • False: begin with ordinary IMAP. Use StartTls when the server requires an explicit STARTTLS upgrade.

If both this property and StartTls are True, implicit TLS takes precedence and STARTTLS is not used.

top
SslAllowedCiphers
Function ComSslAllowedCiphers Returns String
Procedure Set ComSslAllowedCiphers String value
Introduced in version 9.5.0.48

Restricts the cipher suites and selected TLS security requirements offered for an IMAP TLS connection.

Leave this property empty to allow all cipher suites implemented by the installed Chilkat version. To restrict negotiation, provide a comma-separated list in preference order, for example:

TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384, TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256

The server chooses from the cipher suites offered by the client; the client cannot force a suite the server does not support.

The list may also contain these policy keywords:

  • rsa1024 or rsa2048 to require a minimum RSA server-key size.
  • secure-renegotiation to require secure TLS renegotiation.
  • best-practices to use the security policy recommended by the installed Chilkat version.

Legacy keywords such as aes256-cbc, aes128-cbc, 3des-cbc, and rc4 remain recognized for compatibility, but explicitly listing acceptable suites is preferred.

top
SslProtocol
Function ComSslProtocol Returns String
Procedure Set ComSslProtocol String value

Selects the TLS protocol version or minimum version allowed for secure IMAP connections.

The complete list of accepted values is:

  • default
  • TLS 1.3
  • TLS 1.2
  • TLS 1.1
  • TLS 1.0
  • SSL 3.0
  • TLS 1.3 or higher
  • TLS 1.2 or higher
  • TLS 1.1 or higher
  • TLS 1.0 or higher

The default is default, which allows Chilkat to negotiate a protocol supported by both client and server. A minimum-version setting is generally more interoperable than requiring one exact version.

top
SslServerCertVerified
Function ComSslServerCertVerified Returns Boolean

Indicates whether the IMAP server certificate chain was successfully verified for the current or most recent TLS connection.

This property reports certificate-chain verification only. It does not report hostname matching or public-key pinning. If hostname matching or pinning is required and the check fails, the connection itself fails.

top
StartTls
Function ComStartTls Returns Boolean
Procedure Set ComStartTls Boolean value

Controls explicit TLS using the IMAP STARTTLS command. The default is False.

  • True: connect in clear text, issue STARTTLS, and then continue through an encrypted channel.
  • False: do not request an explicit TLS upgrade.

Explicit TLS is commonly used on port 143. For implicit TLS, set Ssl to True and normally use port 993. If both properties are True, Ssl takes precedence.

top
TlsCipherSuite
Function ComTlsCipherSuite Returns String
Introduced in version 9.5.0.49

Contains the cipher suite negotiated for the current or most recent TLS connection, for example TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384.

The value is empty before a TLS connection has been established or after a failed TLS negotiation.

top
TlsPinSet
Function ComTlsPinSet Returns String
Procedure Set ComTlsPinSet String value
Introduced in version 9.5.0.55

Specifies one or more expected SPKI fingerprints for TLS public-key pinning. If none of the configured pins matches the server certificate, the TLS handshake fails.

Pinning supplements normal certificate-chain verification; it does not replace it. A matching pin does not make an expired or otherwise invalid certificate acceptable. When a pin set is configured, pin matching is enforced even if RequireSslCertVerify is False.

The format is:

hashAlgorithm, encoding, fingerprint1, fingerprint2, ...

Example:

sha256, base64, lKg1SIqyhPSK19tlPbjl8s02yChsVTDklQpkMCHvsTE=

Supported hash algorithms include sha1, sha256, sha384, sha512, md2, md5, haval, ripemd128, ripemd160, ripemd256, and ripemd320. Supported encodings include base64, hex, and other Chilkat-supported binary encodings.

More Information and Examples
top
TlsVersion
Function ComTlsVersion Returns String
Introduced in version 9.5.0.49

Contains the protocol version negotiated for the current or most recent TLS connection, such as TLS 1.2 or TLS 1.3.

The value is empty before a TLS connection has been established or after a failed TLS negotiation.

top
UidNext
Function ComUidNext Returns Integer

Contains the mailbox's reported UIDNEXT value—the UID expected to be assigned to the next appended message.

The value is 0 when no mailbox is selected or when the server did not provide UIDNEXT.

top
UidValidity
Function ComUidValidity Returns Integer

Contains the UIDVALIDITY value of the currently selected mailbox, or 0 when no mailbox is selected.

An application that stores message UIDs should also store this value. If UIDVALIDITY changes in a later session, previously stored UIDs must no longer be assumed to identify the same messages.

top
UncommonOptions
Function ComUncommonOptions Returns String
Procedure Set ComUncommonOptions String value
Introduced in version 9.5.0.80

Provides comma-separated compatibility or platform-specific options for uncommon cases. The default is an empty string, and most applications should leave it unchanged.

  • ProtectFromVpn: on Android, bypasses an installed or active VPN.
  • EnableTls13: legacy option that enabled offering TLS 1.3 in versions where it was not yet enabled by default.

More Information and Examples
top
VerboseLogging
Function ComVerboseLogging Returns Boolean
Procedure Set ComVerboseLogging Boolean value

If set to True, then the contents of LastErrorText (or LastErrorXml, or LastErrorHtml) may contain more verbose information. The default value is False. Verbose logging should only be used for debugging. The potentially large quantity of logged information may adversely affect peformance.

top
Version
Function ComVersion Returns String

Version of the component/library, such as "10.1.0"

More Information and Examples
top

Methods

AddPfxSourceBd
Function ComAddPfxSourceBd cComChilkatBinData bd String password Returns Boolean
Introduced in version 11.0.0

Adds the PKCS #12/PFX data in the BinData in bd as a source of certificates and private keys for S/MIME processing.

password contains the PFX password. Call this method once for each additional source.

Returns True for success, False for failure.

top
AddPfxSourceData
Function ComAddPfxSourceData Variant pfxBytes String pfxPassword Returns Boolean
Introduced in version 9.5.0.46

Adds a PKCS #12/PFX source that may be searched for certificates and private keys needed for S/MIME decryption or signature processing.

pfxBytes contains the PFX bytes, and pfxPassword contains its password. Call this method once for each additional source. Common file extensions are .pfx and .p12.

Returns True for success, False for failure.

top
AddPfxSourceFile
Function ComAddPfxSourceFile String pfxFilePath String pfxPassword Returns Boolean

Adds a PKCS #12/PFX file that may be searched for certificates and private keys needed for S/MIME decryption or signature processing.

pfxFilePath is the local filesystem path of the PFX file, and pfxPassword contains its password. Call this method once for each additional source.

On Windows, system certificate stores are also searched automatically. On macOS, the Keychain is searched automatically.

Returns True for success, False for failure.

More Information and Examples
top
AppendMail
Function ComAppendMail String mailbox cComChilkatEmail email Returns Boolean

Appends the Email in email to the mailbox named by mailbox.

AppendSeen controls the initial \Seen flag. After success, AppendUid contains the UID reported by the server, or 0 if no UID was reported, and LastAppendedMime contains the MIME sent.

Rendering for the append does not generate or replace email's Date, Message-ID, or MIME boundary values. If email uses an 8bit or binary transfer encoding that would produce non-text binary bytes, Chilkat changes the rendered transfer encoding to a text-safe encoding such as Base64.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
AppendMailAsync (1)
Function ComAppendMailAsync String mailbox cComChilkatEmail email Returns cComChilkatTask

Creates an asynchronous task to call the AppendMail method with the arguments provided.

Returns null on failure

More Information and Examples
top
AppendMime
Function ComAppendMime String mailbox String mimeText Returns Boolean

Appends the complete RFC 822/MIME message in mimeText to the mailbox named by mailbox.

AppendSeen controls the initial \Seen flag. After success, AppendUid contains the UID reported by the server, or 0 if no UID was reported, and LastAppendedMime contains the MIME sent.

The MIME text is sent exactly as supplied. Chilkat does not normalize line endings, add a final CRLF, or re-encode headers or body content. The supplied text must not contain non-text binary bytes.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
AppendMimeAsync (1)
Function ComAppendMimeAsync String mailbox String mimeText Returns cComChilkatTask

Creates an asynchronous task to call the AppendMime method with the arguments provided.

Returns null on failure

top
AppendMimeWithDateStr
Function ComAppendMimeWithDateStr String mailbox String mimeText String internalDateStr Returns Boolean

Appends the MIME message in mimeText to the mailbox named by mailbox while explicitly setting the server-side internal date from internalDateStr.

internalDateStr is an RFC 822 date/time string, for example Fri, 10 Jul 2026 20:15:30 GMT. The internal date is mailbox metadata and is distinct from the message's Date header. AppendSeen controls the initial \Seen flag.

The MIME text is sent exactly as supplied. Chilkat does not normalize line endings, add a final CRLF, or re-encode headers or body content. The supplied text must not contain non-text binary bytes.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
AppendMimeWithDateStrAsync (1)
Function ComAppendMimeWithDateStrAsync String mailbox String mimeText String internalDateStr Returns cComChilkatTask

Creates an asynchronous task to call the AppendMimeWithDateStr method with the arguments provided.

Returns null on failure

top
AppendMimeWithFlags
Function ComAppendMimeWithFlags String mailbox String mimeText Boolean seen Boolean flagged Boolean answered Boolean draft Returns Boolean

Appends the MIME message in mimeText to the mailbox named by mailbox and sets its initial system flags.

  • seen controls \Seen.
  • flagged controls \Flagged.
  • answered controls \Answered.
  • draft controls \Draft.

Use True to set a flag and False to leave it unset. The explicit flag arguments are used instead of AppendSeen.

The MIME text is sent exactly as supplied. Chilkat does not normalize line endings, add a final CRLF, or re-encode headers or body content. The supplied text must not contain non-text binary bytes.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
AppendMimeWithFlagsAsync (1)
Function ComAppendMimeWithFlagsAsync String mailbox String mimeText Boolean seen Boolean flagged Boolean answered Boolean draft Returns cComChilkatTask

Creates an asynchronous task to call the AppendMimeWithFlags method with the arguments provided.

Returns null on failure

top
AppendMimeWithFlagsSb
Function ComAppendMimeWithFlagsSb String mailbox cComChilkatStringBuilder sbMime Boolean seen Boolean flagged Boolean answered Boolean draft Returns Boolean
Introduced in version 9.5.0.62

Appends the MIME contained in the StringBuilder in sbMime to mailbox mailbox and sets its initial system flags.

  • seen controls \Seen.
  • flagged controls \Flagged.
  • answered controls \Answered.
  • draft controls \Draft.

The explicit flag arguments are used instead of AppendSeen.

The MIME text is sent exactly as supplied. Chilkat does not normalize line endings, add a final CRLF, or re-encode headers or body content. The supplied text must not contain non-text binary bytes.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
AppendMimeWithFlagsSbAsync (1)
Function ComAppendMimeWithFlagsSbAsync String mailbox cComChilkatStringBuilder sbMime Boolean seen Boolean flagged Boolean answered Boolean draft Returns cComChilkatTask
Introduced in version 9.5.0.62

Creates an asynchronous task to call the AppendMimeWithFlagsSb method with the arguments provided.

Returns null on failure

top
Capability
Function ComCapability Returns String

Sends the IMAP CAPABILITY command and returns the server's raw capability response.

Use HasCapability to test the returned text for a particular capability such as IDLE, MOVE, SORT, or QUOTA.

Returns null on failure

top
CapabilityAsync (1)
Function ComCapabilityAsync Returns cComChilkatTask

Creates an asynchronous task to call the Capability method with the arguments provided.

Returns null on failure

top
CheckConnection
Function ComCheckConnection Returns Boolean
Introduced in version 9.5.0.46

Checks whether the underlying TCP socket is currently connected to the IMAP server.

This performs a low-level socket-state check and does not send an IMAP command. To verify that the server is responsive and the session remains usable, call Noop.

More Information and Examples
top
ClearSessionLog
Procedure ComClearSessionLog

Clears the in-memory text returned by SessionLog.

Session logging remains enabled or disabled according to KeepSessionLog.

More Information and Examples
top
CloseMailbox
Function ComCloseMailbox String mailbox Returns Boolean

Closes the currently selected mailbox while keeping the authenticated IMAP connection open.

mailbox is retained for backward compatibility but is ignored. It may be the empty string. Messages marked with \Deleted are permanently removed as part of the close operation. After success, SelectedMailbox is empty, but another mailbox can be selected on the same connection.

Returns True for success, False for failure.

More Information and Examples
top
CloseMailboxAsync (1)
Function ComCloseMailboxAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the CloseMailbox method with the arguments provided.

Returns null on failure

top
Connect
Function ComConnect String domainName Returns Boolean

Establishes a TCP connection to the IMAP server identified by domainName but does not authenticate.

domainName may be a hostname, IPv4 address, or IPv6 address. Configure Port, Ssl, StartTls, proxy settings, and timeouts before calling this method. The TLS hostname is used for Server Name Indication (SNI) and certificate hostname comparison. Call Login after the connection succeeds.

If this method is called while already connected, Chilkat tears down the existing connection and establishes a new connection to domainName. This applies even when domainName names the same server.

Imap does not automatically reconnect after a connection is dropped. The application must call this method again, authenticate again, reselect a mailbox when needed, and retry the interrupted operation.

Connection failures can also be caused by DNS, local or remote firewalls, antivirus software, routing, or other network infrastructure outside Chilkat.

Returns True for success, False for failure.

top
ConnectAsync (1)
Function ComConnectAsync String domainName Returns cComChilkatTask

Creates an asynchronous task to call the Connect method with the arguments provided.

Returns null on failure

top
Copy
Function ComCopy Variant msgId Boolean bUid String copyToMailbox Returns Boolean

Copies one message from the currently selected mailbox to the destination mailbox in copyToMailbox.

msgId identifies the source message. If bUid is True, msgId is a UID; otherwise, msgId is a sequence number. The original message remains in the selected mailbox.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
CopyAsync (1)
Function ComCopyAsync Variant msgId Boolean bUid String copyToMailbox Returns cComChilkatTask

Creates an asynchronous task to call the Copy method with the arguments provided.

Returns null on failure

top
CopyMultiple
Function ComCopyMultiple cComMessageSet messageSet String copyToMailbox Returns Boolean

Copies the messages identified by the MessageSet in messageSet from the selected mailbox to destination mailbox copyToMailbox using one IMAP command.

MessageSet.HasUids determines whether messageSet contains UIDs or sequence numbers. For sequence numbers, one invalid value causes the entire command to fail and no messages are copied. For UIDs, nonexistent values are silently ignored and valid messages are copied. The original messages remain in the selected mailbox.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
CopyMultipleAsync (1)
Function ComCopyMultipleAsync cComMessageSet messageSet String copyToMailbox Returns cComChilkatTask

Creates an asynchronous task to call the CopyMultiple method with the arguments provided.

Returns null on failure

top
CopySequence
Function ComCopySequence Integer startSeqNum Integer count String copyToMailbox Returns Boolean

Copies a contiguous range of messages, identified by sequence number, from the selected mailbox to the destination mailbox in copyToMailbox.

startSeqNum is the first sequence number and count is the number of messages to copy. IMAP sequence numbers begin at 1 and can change when messages are expunged.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
CopySequenceAsync (1)
Function ComCopySequenceAsync Integer startSeqNum Integer count String copyToMailbox Returns cComChilkatTask

Creates an asynchronous task to call the CopySequence method with the arguments provided.

Returns null on failure

top
CreateMailbox
Function ComCreateMailbox String mailbox Returns Boolean

Creates the mailbox named by mailbox on the IMAP server.

Use the hierarchy delimiter reported in SeparatorChar when creating a nested mailbox. In IMAP terminology, mailbox and folder are synonymous.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
CreateMailboxAsync (1)
Function ComCreateMailboxAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the CreateMailbox method with the arguments provided.

Returns null on failure

top
DeleteMailbox
Function ComDeleteMailbox String mailbox Returns Boolean

Deletes the mailbox named by mailbox from the IMAP server.

This deletes the mailbox itself, not merely the messages it contains. Server rules may require the mailbox to be empty first.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
DeleteMailboxAsync (1)
Function ComDeleteMailboxAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the DeleteMailbox method with the arguments provided.

Returns null on failure

top
Disconnect
Function ComDisconnect Returns Boolean

Closes the connection to the IMAP server.

A failure indicates that the connection could not be closed cleanly; the socket is nevertheless no longer intended for further use. In many applications, a disconnect failure during shutdown can be treated as nonfatal.

Returns True for success, False for failure.

More Information and Examples
top
DisconnectAsync (1)
Function ComDisconnectAsync Returns cComChilkatTask

Creates an asynchronous task to call the Disconnect method with the arguments provided.

Returns null on failure

top
ExamineMailbox
Function ComExamineMailbox String mailbox Returns Boolean

Opens the mailbox in mailbox as read-only.

Use this instead of SelectMailbox when the application must not change message flags or mailbox state. Successful examination updates properties such as NumMessages, UidValidity, and UidNext.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
ExamineMailboxAsync (1)
Function ComExamineMailboxAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the ExamineMailbox method with the arguments provided.

Returns null on failure

top
Expunge
Function ComExpunge Returns Boolean

Permanently removes all messages marked with the \Deleted flag from the currently selected mailbox.

The mailbox remains selected and the authenticated connection remains open. Expunging can change sequence numbers for the remaining messages.

Returns True for success, False for failure.

More Information and Examples
top
ExpungeAsync (1)
Function ComExpungeAsync Returns cComChilkatTask

Creates an asynchronous task to call the Expunge method with the arguments provided.

Returns null on failure

top
ExpungeAndClose
Function ComExpungeAndClose Returns Boolean

Permanently removes all messages marked with \Deleted from the selected mailbox and then closes the mailbox.

After success, SelectedMailbox is empty. The authenticated IMAP connection remains open and can be used to select another mailbox.

Returns True for success, False for failure.

More Information and Examples
top
ExpungeAndCloseAsync (1)
Function ComExpungeAndCloseAsync Returns cComChilkatTask

Creates an asynchronous task to call the ExpungeAndClose method with the arguments provided.

Returns null on failure

top
FetchAttachment
Function ComFetchAttachment cComChilkatEmail emailObject Integer attachmentIndex String saveToPath Returns Boolean

Obtains attachment attachmentIndex from the Email in emailObject and writes it to the filesystem path in saveToPath. Attachment indexes are zero-based.

saveToPath may be a filename, a relative path ending in a filename, or an absolute path ending in a filename. Missing parent directories are not created. An existing file is overwritten. A failed operation should not leave a partial output file.

If emailObject already contains the attachment bytes, the data is saved without contacting the IMAP server. If emailObject was fetched without attachment bodies, Chilkat uses its ckx-imap-* metadata to locate and download the requested MIME part. The same IMAP session is not required, and a copied Email can be used if the metadata is preserved.

The corresponding mailbox must be selected when a server fetch is required. If ckx-imap-isUid is YES, the permanent UID is used and the operation can work after reconnecting. If it is NO, the stored value is a sequence number, which can identify a different message after an expunge. UID-based metadata is therefore preferred for deferred attachment operations. The method fails if the referenced message or MIME part no longer exists, such as after the message is moved or expunged.

Related MIME parts used by an HTML body are not counted as ordinary attachments. Signed and encrypted messages are fetched in full because their complete MIME is required.

Returns True for success, False for failure.

More Information and Examples
top
FetchAttachmentAsync (1)
Function ComFetchAttachmentAsync cComChilkatEmail emailObject Integer attachmentIndex String saveToPath Returns cComChilkatTask

Creates an asynchronous task to call the FetchAttachment method with the arguments provided.

Returns null on failure

top
FetchAttachmentBd
Function ComFetchAttachmentBd cComChilkatEmail email Integer attachmentIndex cComChilkatBinData binData Returns Boolean
Introduced in version 9.5.0.62

Obtains attachment attachmentIndex from the Email in email and stores its bytes in the BinData in binData.

Attachment indexes are zero-based. binData is always cleared first. On success it contains the complete attachment bytes; on failure it remains empty.

See FetchAttachment for details about downloading attachment data not already present in email.

Returns True for success, False for failure.

More Information and Examples
top
FetchAttachmentBdAsync (1)
Function ComFetchAttachmentBdAsync cComChilkatEmail email Integer attachmentIndex cComChilkatBinData binData Returns cComChilkatTask
Introduced in version 9.5.0.62

Creates an asynchronous task to call the FetchAttachmentBd method with the arguments provided.

Returns null on failure

top
FetchAttachmentBytes
Function ComFetchAttachmentBytes cComChilkatEmail email Integer attachIndex Returns Variant

Obtains attachment attachIndex from the Email in email and returns its bytes. Attachment indexes are zero-based.

If the attachment is not already present in email, Chilkat downloads it from the IMAP server using the message metadata stored in the email. See FetchAttachment for attachment-fetching details.

Returns null on failure

top
FetchAttachmentBytesAsync (1)
Function ComFetchAttachmentBytesAsync cComChilkatEmail email Integer attachIndex Returns cComChilkatTask

Creates an asynchronous task to call the FetchAttachmentBytes method with the arguments provided.

Returns null on failure

top
FetchAttachmentSb
Function ComFetchAttachmentSb cComChilkatEmail email Integer attachmentIndex String charset cComChilkatStringBuilder sb Returns Boolean
Introduced in version 9.5.0.62

Obtains text attachment attachmentIndex from the Email in email, decodes it using the charset in charset, and stores the text in the StringBuilder in sb.

Attachment indexes are zero-based. sb is always cleared first. On success it contains the complete decoded attachment text; on failure it remains empty. Use this method only for text attachments.

See FetchAttachment for details about downloading data not already present in email.

Returns True for success, False for failure.

top
FetchAttachmentSbAsync (1)
Function ComFetchAttachmentSbAsync cComChilkatEmail email Integer attachmentIndex String charset cComChilkatStringBuilder sb Returns cComChilkatTask
Introduced in version 9.5.0.62

Creates an asynchronous task to call the FetchAttachmentSb method with the arguments provided.

Returns null on failure

top
FetchAttachmentString
Function ComFetchAttachmentString cComChilkatEmail emailObject Integer attachmentIndex String charset Returns String

Obtains text attachment attachmentIndex from the Email in emailObject and decodes its bytes using the character encoding named by charset.

Use this only when the attachment contains text. Attachment indexes are zero-based. See FetchAttachment for information about downloading attachment data that is not already present in emailObject.

Returns null on failure

More Information and Examples
top
FetchAttachmentStringAsync (1)
Function ComFetchAttachmentStringAsync cComChilkatEmail emailObject Integer attachmentIndex String charset Returns cComChilkatTask

Creates an asynchronous task to call the FetchAttachmentString method with the arguments provided.

Returns null on failure

top
FetchChunk2
Function ComFetchChunk2 Integer seqnum Integer count cComMessageSet failedSet cComMessageSet fetchedSet cComChilkatEmailBundle bundle Returns Boolean
Introduced in version 11.0.0

Attempts to download count full messages beginning with sequence number seqnum.

failedSet and fetchedSet are cleared before use. failedSet receives sequence numbers that failed or were not yet fetched, fetchedSet receives sequence numbers fetched successfully, and both sets have MessageSet.HasUids set to False. Downloaded messages are appended to the EmailBundle in bundle, which is not cleared.

Sequence numbers beyond the end of the mailbox are added to failedSet. The method can return success even when failedSet is nonempty; success indicates that the requested range was processed, not that every sequence number existed.

If a network failure occurs, messages already fetched remain in bundle, fetchedSet retains the successfully fetched sequence numbers, and failedSet contains the failed and not-yet-fetched sequence numbers. Processing stops and the connection must be considered unusable.

Returns True for success, False for failure.

More Information and Examples
top
FetchChunk2Async (1)
Function ComFetchChunk2Async Integer seqnum Integer count cComMessageSet failedSet cComMessageSet fetchedSet cComChilkatEmailBundle bundle Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the FetchChunk2 method with the arguments provided.

Returns null on failure

top
FetchEmail
Function ComFetchEmail Boolean headerOnly Variant msgId Boolean bUid cComChilkatEmail email Returns Boolean
Introduced in version 11.0.0

Downloads one message or its headers into the Email in email.

  • headerOnly = True: download headers only.
  • headerOnly = False: download the full message.
  • bUid = True: msgId is a UID.
  • bUid = False: msgId is a sequence number.

On success, email is replaced with the fetched email. On failure, email remains unchanged.

A header-only result contains no body or attachment bodies, but includes ckx-imap-* metadata for the message identifier, flags, total size, and attachment information. For a full download, ordinary attachment bodies are included according to AutoDownloadAttachments. PeekMode controls whether a full fetch sets \Seen; a header-only fetch does not set it.

Returns True for success, False for failure.

top
FetchEmailAsync (1)
Function ComFetchEmailAsync Boolean headerOnly Variant msgId Boolean bUid cComChilkatEmail email Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the FetchEmail method with the arguments provided.

Returns null on failure

top
FetchFlags
Function ComFetchFlags Variant msgId Boolean bUid Returns String

Returns the space-separated IMAP flags for the message identified by msgId.

If bUid is True, msgId is a UID; otherwise, it is a sequence number. A result might be \Flagged \Seen $label1.

An existing message with no flags returns the empty string. A nonexistent message is an error.

Returns null on failure

More Information and Examples
top
FetchFlagsAsync (1)
Function ComFetchFlagsAsync Variant msgId Boolean bUid Returns cComChilkatTask

Creates an asynchronous task to call the FetchFlags method with the arguments provided.

Returns null on failure

top
FetchMsgSet
Function ComFetchMsgSet Boolean headersOnly cComMessageSet msgSet cComChilkatEmailBundle bundle Returns Boolean
Introduced in version 11.0.0

Downloads the existing messages identified by the MessageSet in msgSet and appends them to the EmailBundle in bundle. bundle is not cleared.

  • headersOnly = True: download headers only.
  • headersOnly = False: download full messages, with ordinary attachments controlled by AutoDownloadAttachments.

MessageSet.HasUids determines whether msgSet contains UIDs or sequence numbers. A MessageSet is a true set, so duplicate identifiers are collapsed before any command is sent. Identifiers that do not exist are omitted without causing the method to fail. Do not rely on insertion order; fetched messages are returned in the order supplied by the IMAP server, normally mailbox order.

If a network failure occurs after some messages have been downloaded, those messages remain appended to bundle, fetching stops immediately, and the connection must be considered unusable. Reconnect, authenticate, and reselect the mailbox before retrying.

Returns True for success, False for failure.

More Information and Examples
top
FetchMsgSetAsync (1)
Function ComFetchMsgSetAsync Boolean headersOnly cComMessageSet msgSet cComChilkatEmailBundle bundle Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the FetchMsgSet method with the arguments provided.

Returns null on failure

top
FetchRange
Function ComFetchRange Boolean headersOnly Integer seqnum Integer count cComChilkatEmailBundle bundle Returns Boolean
Introduced in version 11.0.0

Downloads count messages beginning with sequence number seqnum and appends them to the EmailBundle in bundle. bundle is not cleared.

  • headersOnly = True: download headers only.
  • headersOnly = False: download full messages, with ordinary attachments controlled by AutoDownloadAttachments.

seqnum and count must both be greater than 0. IMAP sequence numbers begin at 1; passing 0 for seqnum, 0 for count, or a negative count fails without changing bundle. Only messages that exist in the requested sequence-number range are appended. Sequence numbers can change after messages are expunged.

If a network failure occurs after some messages have been downloaded, those messages remain appended to bundle, fetching stops immediately, and the connection must be considered unusable.

Returns True for success, False for failure.

top
FetchRangeAsync (1)
Function ComFetchRangeAsync Boolean headersOnly Integer seqnum Integer count cComChilkatEmailBundle bundle Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the FetchRange method with the arguments provided.

Returns null on failure

top
FetchSingleAsMime
Function ComFetchSingleAsMime Variant msgId Boolean bUid Returns String

Downloads one message and returns its MIME source as a string.

If bUid is True, msgId is a UID; otherwise, msgId is a sequence number. Ordinary attachment bodies are included according to AutoDownloadAttachments.

Chilkat interprets the received MIME bytes as UTF-8. MIME using Base64 or quoted-printable transfer encoding is safe because the encoded bytes are ASCII. Raw 8bit or binary content, or unencoded text in another charset such as ISO-8859-1 or Shift_JIS, can be misinterpreted or cause an error. Use FetchSingleBd whenever byte-exact MIME is required.

Returns null on failure

top
FetchSingleAsMimeAsync (1)
Function ComFetchSingleAsMimeAsync Variant msgId Boolean bUid Returns cComChilkatTask

Creates an asynchronous task to call the FetchSingleAsMime method with the arguments provided.

Returns null on failure

top
FetchSingleAsMimeSb
Function ComFetchSingleAsMimeSb Variant msgId Boolean bUid cComChilkatStringBuilder sbMime Returns Boolean
Introduced in version 9.5.0.62

Downloads one message's MIME into the StringBuilder in sbMime.

If bUid is True, msgId is a UID; otherwise, msgId is a sequence number. Ordinary attachment bodies are included according to AutoDownloadAttachments. sbMime is cleared before the operation; on failure it remains empty.

Chilkat interprets the received MIME bytes as UTF-8. MIME using Base64 or quoted-printable transfer encoding is safe because the encoded bytes are ASCII. Raw 8bit or binary content, or unencoded text in another charset such as ISO-8859-1 or Shift_JIS, can be misinterpreted or cause an error. Use FetchSingleBd whenever byte-exact MIME is required.

Returns True for success, False for failure.

top
FetchSingleAsMimeSbAsync (1)
Function ComFetchSingleAsMimeSbAsync Variant msgId Boolean bUid cComChilkatStringBuilder sbMime Returns cComChilkatTask
Introduced in version 9.5.0.62

Creates an asynchronous task to call the FetchSingleAsMimeSb method with the arguments provided.

Returns null on failure

top
FetchSingleBd
Function ComFetchSingleBd Variant msgId Boolean bUid cComChilkatBinData mimeData Returns Boolean
Introduced in version 9.5.0.76

Downloads one message's MIME bytes into the BinData in mimeData.

If bUid is True, msgId is a UID; otherwise, it is a sequence number. Ordinary attachment bodies are included according to AutoDownloadAttachments, and PeekMode controls whether the fetch sets \Seen.

mimeData is cleared before the operation. On success it contains the downloaded MIME bytes; on failure it remains empty.

Returns True for success, False for failure.

top
FetchSingleBdAsync (1)
Function ComFetchSingleBdAsync Variant msgId Boolean bUid cComChilkatBinData mimeData Returns cComChilkatTask
Introduced in version 9.5.0.76

Creates an asynchronous task to call the FetchSingleBd method with the arguments provided.

Returns null on failure

top
FetchSingleHeaderAsMime
Function ComFetchSingleHeaderAsMime Variant msgId Boolean bUID Returns String

Downloads and returns the MIME header block for one message, without downloading the body.

If bUID is True, msgId is a UID; otherwise, msgId is a sequence number.

Returns null on failure

More Information and Examples
top
FetchSingleHeaderAsMimeAsync (1)
Function ComFetchSingleHeaderAsMimeAsync Variant msgId Boolean bUID Returns cComChilkatTask

Creates an asynchronous task to call the FetchSingleHeaderAsMime method with the arguments provided.

Returns null on failure

top
GetMailAttachFilename
Function ComGetMailAttachFilename cComChilkatEmail email Integer attachIndex Returns String

Returns the filename for attachment attachIndex represented by email. Attachment indexes are zero-based.

This method can obtain the filename from ckx-imap-* metadata in a header-only email even when the attachment body has not been downloaded.

Returns null on failure

top
GetMailAttachSize
Function ComGetMailAttachSize cComChilkatEmail email Integer attachIndex Returns Integer

Returns the size in bytes of attachment attachIndex represented by email. Attachment indexes are zero-based.

This method can obtain the size from ckx-imap-* metadata in a header-only email even when the attachment body has not been downloaded.

top
GetMailboxStatus
Function ComGetMailboxStatus String mailbox Returns String
Introduced in version 9.5.0.46

Sends the IMAP STATUS command for the mailbox in mailbox and returns the reported values as XML attributes.

  • messages: total number of messages.
  • recent: messages having the \Recent flag.
  • uidnext: expected UID for the next appended message.
  • uidvalidity: mailbox UID-validity value.
  • unseen: messages without the \Seen flag.
<status messages="240" recent="0" uidnext="3674" uidvalidity="3" unseen="213" />

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns null on failure

More Information and Examples
top
GetMailboxStatusAsync (1)
Function ComGetMailboxStatusAsync String mailbox Returns cComChilkatTask
Introduced in version 9.5.0.46

Creates an asynchronous task to call the GetMailboxStatus method with the arguments provided.

Returns null on failure

top
GetMailFlag
Function ComGetMailFlag cComChilkatEmail email String flagName Returns Integer

Returns the state of the flag named by flagName from the IMAP metadata stored in the Email in email.

  • 1: the flag is set.
  • 0: the flag is not set.
  • -1: the required ckx-imap-* metadata is missing.

Standard flags include \Seen, \Answered, \Flagged, \Draft, and \Deleted. Custom keywords such as $label1 or NonJunk are also supported.

Integer-returning methods do not use LastMethodSuccess to report this condition; test the return value directly.

top
GetMailNumAttach
Function ComGetMailNumAttach cComChilkatEmail email Returns Integer

Returns the number of ordinary attachments represented by email.

This method also works with a header-only email or an email fetched while AutoDownloadAttachments was False. In those cases it reads the ckx-imap-numAttach metadata, even though the Email object's downloaded attachment count can be 0.

top
GetMailSize
Function ComGetMailSize cComChilkatEmail email Returns Integer

Returns the complete server-reported size of the Email in email, in bytes, including attachment data.

This value may be available even when only the message headers were downloaded.

top
GetQuota
Function ComGetQuota String quotaRoot Returns String
Introduced in version 9.5.0.58

Sends the IMAP GETQUOTA command for the quota root in quotaRoot and returns the server response as JSON.

The server must advertise the IMAP QUOTA capability.

Returns null on failure

More Information and Examples
top
GetQuotaAsync (1)
Function ComGetQuotaAsync String quotaRoot Returns cComChilkatTask
Introduced in version 9.5.0.58

Creates an asynchronous task to call the GetQuota method with the arguments provided.

Returns null on failure

top
GetQuotaRoot
Function ComGetQuotaRoot String mailboxName Returns String
Introduced in version 9.5.0.58

Sends the IMAP GETQUOTAROOT command for the mailbox in mailboxName and returns the server response as JSON. The server must advertise the IMAP QUOTA capability.

A response can contain both the mailbox-to-root mapping and the quota values:

{
  "QUOTAROOT": {"mailbox":"Inbox","root":"Mailbox"},
  "QUOTA": {"root":"Mailbox","resource":"STORAGE","used":9,"max":256000}
}

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns null on failure

top
GetQuotaRootAsync (1)
Function ComGetQuotaRootAsync String mailboxName Returns cComChilkatTask
Introduced in version 9.5.0.58

Creates an asynchronous task to call the GetQuotaRoot method with the arguments provided.

Returns null on failure

top
GetServerCert
Function ComGetServerCert cComChilkatCert cert Returns Boolean
Introduced in version 11.0.0

Stores the certificate presented by the IMAP server for the current or most recent TLS connection in the Cert object supplied as cert.

This is useful for certificate inspection, diagnostics, or implementing application-specific trust checks.

Returns True for success, False for failure.

More Information and Examples
top
HasCapability
Function ComHasCapability String name String capabilityResponse Returns Boolean
Introduced in version 9.5.0.58

Tests whether the capability named by name appears in the raw capability response in capabilityResponse.

capabilityResponse is typically the string returned by Capability. Capability-name matching follows IMAP capability-token semantics.

top
IdleCheck
Function ComIdleCheck Integer timeoutMs Returns String
Introduced in version 9.5.0.26

Waits up to timeoutMs milliseconds for unsolicited mailbox updates after IdleStart has entered IMAP IDLE mode.

timeoutMs = 0 performs a strict poll: it checks for already available data and returns immediately. Positive values wait for up to the requested time, including very large values. If the connection is lost while waiting, the method fails.

This method does not send a polling command. It consumes the notifications currently waiting on the existing connection and returns them as XML. A second call returns only notifications that arrived after the previous call.

  • flags: flags changed for a message.
  • expunge: a sequence number was removed.
  • exists: the mailbox message count changed.
  • recent: the recent-message count changed.
  • raw: an unrecognized response line retained for diagnostics.
<idle><exists>115</exists><recent>1</recent></idle>

When no update is available, the result is <idle></idle>. An exists notification does not automatically change NumMessages.

Chilkat does not automatically refresh IDLE. The application should periodically call IdleDone and IdleStart, typically before 29 minutes have elapsed, to prevent servers with a 30-minute limit from dropping the connection.

Returns null on failure

top
IdleCheckAsync (1)
Function ComIdleCheckAsync Integer timeoutMs Returns cComChilkatTask
Introduced in version 9.5.0.26

Creates an asynchronous task to call the IdleCheck method with the arguments provided.

Returns null on failure

top
IdleDone
Function ComIdleDone Returns Boolean
Introduced in version 9.5.0.26

Ends IMAP IDLE mode by sending the protocol's DONE continuation.

The authenticated connection remains open and usable. Calling this method when IDLE is not active fails.

Applications maintaining a long-lived IDLE connection should call this method shortly before the server's IDLE limit, commonly at about 29 minutes, and then immediately call IdleStart again.

Returns True for success, False for failure.

top
IdleDoneAsync (1)
Function ComIdleDoneAsync Returns cComChilkatTask
Introduced in version 9.5.0.26

Creates an asynchronous task to call the IdleDone method with the arguments provided.

Returns null on failure

top
IdleStart
Function ComIdleStart Returns Boolean
Introduced in version 9.5.0.26

Sends the IMAP IDLE command and begins listening for unsolicited mailbox updates.

The session must be connected, authenticated, and have a mailbox selected with SelectMailbox or ExamineMailbox. The server must advertise the IDLE capability.

Calling this method while IDLE is already active fails. While IDLE is active, any other method that sends an IMAP command also fails; call IdleDone first.

Chilkat does not automatically renew IDLE. To avoid common server time limits, the application should end and restart IDLE before the server timeout, typically about every 29 minutes.

Returns True for success, False for failure.

top
IdleStartAsync (1)
Function ComIdleStartAsync Returns cComChilkatTask
Introduced in version 9.5.0.26

Creates an asynchronous task to call the IdleStart method with the arguments provided.

Returns null on failure

top
IsConnected
Function ComIsConnected Returns Boolean

Returns the last known connection state without sending data to the IMAP server.

A True result does not prove that an idle connection is still usable. Call Noop to send a command and verify that the server responds.

More Information and Examples
top
IsLoggedIn
Function ComIsLoggedIn Returns Boolean

Indicates whether this object is in an authenticated IMAP session.

This reports the last known state and does not send a command to the server.

top
LoadTaskCaller
Function ComLoadTaskCaller cComChilkatTask task Returns Boolean
Introduced in version 9.5.0.80

Associates this Imap object with the original Imap caller that created the asynchronous Task in task.

This works with a task returned by any Imap async method, and the task does not need to be complete. The operation does not copy the caller's state; this object becomes another reference to the same underlying Imap state. Any previously associated state in this object is replaced.

Use this when code has a Task—for example in a task-completed callback—but no longer has a reference to the object that started the async operation.

Returns True for success, False for failure.

top
Login
Function ComLogin String loginName String password Returns Boolean

Authenticates the connected IMAP session using the login name in loginName and the credential in password.

Call Connect first. The mechanism is selected by AuthMethod.

For XOAUTH2, loginName is the normal IMAP login name or email address and password is the raw OAuth 2.0 access token without a Bearer prefix. A failed XOAUTH2 login leaves the connection open so the application may correct the credentials and try again.

Do not call this method again after the session is already authenticated. A repeated login attempt fails, although the existing authenticated session remains logged in.

Returns True for success, False for failure.

top
LoginAsync (1)
Function ComLoginAsync String loginName String password Returns cComChilkatTask

Creates an asynchronous task to call the Login method with the arguments provided.

Returns null on failure

top
LoginSecure
Function ComLoginSecure cComChilkatSecureString loginName cComChilkatSecureString password Returns Boolean
Introduced in version 9.5.0.71

Authenticates the connected IMAP session using the SecureString login name in loginName and credential in password.

This is the secure-string counterpart of Login. The authentication mechanism is selected by AuthMethod.

For XOAUTH2, loginName contains the normal login name or email address and password contains the raw access token without a Bearer prefix.

Returns True for success, False for failure.

top
LoginSecureAsync (1)
Function ComLoginSecureAsync cComChilkatSecureString loginName cComChilkatSecureString password Returns cComChilkatTask
Introduced in version 9.5.0.71

Creates an asynchronous task to call the LoginSecure method with the arguments provided.

Returns null on failure

top
Logout
Function ComLogout Returns Boolean

Sends the IMAP LOGOUT command and ends the authenticated session.

The server normally closes the connection as part of a successful logout.

Returns True for success, False for failure.

More Information and Examples
top
LogoutAsync (1)
Function ComLogoutAsync Returns cComChilkatTask

Creates an asynchronous task to call the Logout method with the arguments provided.

Returns null on failure

top
MbxList
Function ComMbxList Boolean subscribed String reference String mbxPattern cComMailboxes mboxes Returns Boolean
Introduced in version 11.0.0

Lists matching mailboxes and appends them to the Mailboxes object in mboxes. mboxes is not cleared on success, so repeated calls on the same object can add duplicate entries. If the method fails, mboxes is unchanged.

  • subscribed = True: list only subscribed mailboxes.
  • subscribed = False: list all matching mailboxes.

reference is the IMAP reference name, usually an empty string. mbxPattern is the mailbox pattern: * matches zero or more hierarchy levels, while % matches one hierarchy level.

Applications may use normal Unicode mailbox names and patterns. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

The method also updates SeparatorChar from the server's response.

Returns True for success, False for failure.

More Information and Examples
top
MbxListAsync (1)
Function ComMbxListAsync Boolean subscribed String reference String mbxPattern cComMailboxes mboxes Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the MbxList method with the arguments provided.

Returns null on failure

top
MoveMessages
Function ComMoveMessages cComMessageSet messageSet String destFolder Returns Boolean
Introduced in version 9.5.0.64

Moves the messages identified by the MessageSet in messageSet from the selected mailbox to destination mailbox destFolder using one IMAP MOVE command.

The server must advertise the MOVE capability. If it does not, this method fails and does not emulate the operation with copy, delete, and expunge commands.

MessageSet.HasUids determines whether messageSet contains UIDs or sequence numbers. For sequence numbers, one invalid value causes complete failure and nothing is moved. For UIDs, nonexistent values are silently ignored and valid messages are moved.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
MoveMessagesAsync (1)
Function ComMoveMessagesAsync cComMessageSet messageSet String destFolder Returns cComChilkatTask
Introduced in version 9.5.0.64

Creates an asynchronous task to call the MoveMessages method with the arguments provided.

Returns null on failure

top
Noop
Function ComNoop Returns Boolean

Sends the IMAP NOOP command and waits for the server response.

This is useful for verifying that an existing authenticated connection is still responsive and for receiving unsolicited mailbox-state updates.

Returns True for success, False for failure.

More Information and Examples
top
NoopAsync (1)
Function ComNoopAsync Returns cComChilkatTask

Creates an asynchronous task to call the Noop method with the arguments provided.

Returns null on failure

top
QueryMbx
Function ComQueryMbx String criteria Boolean bUid cComMessageSet msgSet Returns Boolean
Introduced in version 11.0.0

Searches the selected mailbox using the IMAP criteria in criteria and stores matching identifiers in the MessageSet in msgSet.

On success, msgSet is replaced with the result. If bUid is True, msgSet contains UIDs and MessageSet.HasUids is True; otherwise, msgSet contains sequence numbers and MessageSet.HasUids is False. If the method fails, msgSet is unchanged. SearchCharset applies when the criteria contain non-ASCII text.

For the special criterion new-email, Chilkat records each UIDNEXT received from SELECT, EXAMINE, or another IMAP response and uses it as the baseline for detecting later UIDs. If no UIDNEXT is available, Chilkat searches for messages having the \Recent flag. Results are always UIDs regardless of bUid, and an empty result clears msgSet.

When SortCriteria is nonempty, Chilkat uses IMAP SORT if the server supports it. Otherwise, it automatically falls back to an ordinary SEARCH.

Returns True for success, False for failure.

top
QueryMbxAsync (1)
Function ComQueryMbxAsync String criteria Boolean bUid cComMessageSet msgSet Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the QueryMbx method with the arguments provided.

Returns null on failure

top
QueryThread
Function ComQueryThread String threadAlg String searchCriteria Boolean bUid cComChilkatJsonObject json Returns Boolean
Introduced in version 11.0.0

Sends the IMAP THREAD command for the selected mailbox.

threadAlg is the threading algorithm, commonly ORDEREDSUBJECT or REFERENCES. searchCriteria contains ordinary IMAP search criteria and is interpreted using SearchCharset. If bUid is True, message identifiers in the result are UIDs; otherwise, they are sequence numbers.

On success, json is completely replaced with the thread hierarchy. On failure, json is unchanged; there is no partial-success JSON result.

The returned JSON has a top-level threads array. Each element represents one thread, and nested arrays encode parent/child relationships. For example:

{"threads":[[1],[2],[3]]}

The server must advertise the IMAP THREAD capability and support the selected algorithm.

Returns True for success, False for failure.

More Information and Examples
top
QueryThreadAsync (1)
Function ComQueryThreadAsync String threadAlg String searchCriteria Boolean bUid cComChilkatJsonObject json Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the QueryThread method with the arguments provided.

Returns null on failure

top
RawCommandBd
Function ComRawCommandBd cComChilkatBinData bdCmd cComChilkatBinData bdResp Returns Boolean
Introduced in version 11.0.0

Sends the raw IMAP command bytes in the BinData in bdCmd and stores the raw response bytes in bdResp.

bdCmd contains the command without an IMAP command tag or trailing CRLF; Chilkat supplies both. bdResp is cleared and replaced with the response.

Use raw commands only for rare server extensions that are not otherwise exposed by the API, have an expected one-line response, and do not change Imap object state such as the selected mailbox, message count, UidNext, or UidValidity. State-changing raw commands can leave cached properties inconsistent with the server.

Returns True for success, False for failure.

More Information and Examples
top
RawCommandBdAsync (1)
Function ComRawCommandBdAsync cComChilkatBinData bdCmd cComChilkatBinData bdResp Returns cComChilkatTask
Introduced in version 11.0.0

Creates an asynchronous task to call the RawCommandBd method with the arguments provided.

Returns null on failure

top
RefetchMailFlags
Function ComRefetchMailFlags cComChilkatEmail email Returns Boolean

Fetches the current IMAP flags for the server message represented by email and updates its ckx-imap-* metadata headers.

Chilkat reads the identifier from ckx-imap-uid and checks ckx-imap-isUid to determine whether it is a UID or sequence number. A copied Email can be used as long as this metadata is preserved.

When ckx-imap-isUid is NO, the stored sequence number may identify a different message after an expunge. UID-based emails are preferred for later operations. Methods such as GetMailFlag read the refreshed flag metadata.

Returns True for success, False for failure.

More Information and Examples
top
RefetchMailFlagsAsync (1)
Function ComRefetchMailFlagsAsync cComChilkatEmail email Returns cComChilkatTask

Creates an asynchronous task to call the RefetchMailFlags method with the arguments provided.

Returns null on failure

top
RenameMailbox
Function ComRenameMailbox String fromMailbox String toMailbox Returns Boolean

Renames the mailbox in fromMailbox to the name in toMailbox.

Changing hierarchy components can also move a mailbox within the server's folder tree, for example from INBOX.old.project to INBOX.archive.project.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

More Information and Examples
top
RenameMailboxAsync (1)
Function ComRenameMailboxAsync String fromMailbox String toMailbox Returns cComChilkatTask

Creates an asynchronous task to call the RenameMailbox method with the arguments provided.

Returns null on failure

top
SelectMailbox
Function ComSelectMailbox String mailbox Returns Boolean

Opens the mailbox in mailbox for read-write access.

A mailbox must be selected before message fetch, search, flag, copy, move, or expunge operations that act on mailbox contents. Successful selection updates SelectedMailbox, NumMessages, UidValidity, and related mailbox-state properties.

Use ExamineMailbox when read-only access is required.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
SelectMailboxAsync (1)
Function ComSelectMailboxAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the SelectMailbox method with the arguments provided.

Returns null on failure

top
SendRawCommand
Function ComSendRawCommand String cmd Returns String

Sends the raw IMAP command text in cmd and returns the raw server response.

Pass the command itself, such as NOOP, without an IMAP command tag or trailing CRLF. Chilkat generates the tag and command line termination.

Use raw commands only for rare server extensions that are not otherwise exposed by the API, have an expected one-line response, and do not change Imap object state such as the selected mailbox, message count, UidNext, or UidValidity. State-changing raw commands can leave cached properties inconsistent with the server.

Returns null on failure

top
SendRawCommandAsync (1)
Function ComSendRawCommandAsync String cmd Returns cComChilkatTask

Creates an asynchronous task to call the SendRawCommand method with the arguments provided.

Returns null on failure

top
SendRawCommandB
Function ComSendRawCommandB String cmd Returns Variant

Sends the raw IMAP command text in cmd and returns the server response as bytes.

Pass the command without an IMAP tag or trailing CRLF; Chilkat supplies both. This is the byte-response counterpart of SendRawCommand.

Use raw commands only for rare server extensions that are not otherwise exposed by the API, have an expected one-line response, and do not change Imap object state such as the selected mailbox, message count, UidNext, or UidValidity. State-changing raw commands can leave cached properties inconsistent with the server.

Returns null on failure

top
SendRawCommandBAsync (1)
Function ComSendRawCommandBAsync String cmd Returns cComChilkatTask

Creates an asynchronous task to call the SendRawCommandB method with the arguments provided.

Returns null on failure

top
SendRawCommandC
Function ComSendRawCommandC Variant cmd Returns Variant

Sends the raw IMAP command bytes in cmd and returns the server response as bytes.

cmd contains the command without an IMAP tag or trailing CRLF; Chilkat supplies both.

Use raw commands only for rare server extensions that are not otherwise exposed by the API, have an expected one-line response, and do not change Imap object state such as the selected mailbox, message count, UidNext, or UidValidity. State-changing raw commands can leave cached properties inconsistent with the server.

Returns null on failure

top
SendRawCommandCAsync (1)
Function ComSendRawCommandCAsync Variant cmd Returns cComChilkatTask

Creates an asynchronous task to call the SendRawCommandC method with the arguments provided.

Returns null on failure

top
SetDecryptCert
Function ComSetDecryptCert cComChilkatCert cert Returns Boolean
Introduced in version 9.5.0.40

Specifies the Cert in cert for decrypting S/MIME messages downloaded by this Imap object.

The certificate must have access to its associated private key. Use SetDecryptCert2 when the private key is supplied separately.

Returns True for success, False for failure.

top
SetDecryptCert2
Function ComSetDecryptCert2 cComChilkatCert cert cComPrivateKey key Returns Boolean

Specifies the certificate in cert and its separately supplied PrivateKey in key for decrypting S/MIME messages.

Use this when the certificate object does not already provide access to the private key.

Returns True for success, False for failure.

More Information and Examples
top
SetFlag
Function ComSetFlag Variant msgId Boolean bUid String flagName Integer value Returns Boolean

Sets or clears one flag on the message identified by msgId in the selected mailbox.

If bUid is True, msgId is a UID; otherwise, it is a sequence number. flagName is the flag name, and value is 1 to set the flag or 0 to clear it.

Standard flags include \Deleted, \Seen, \Answered, \Flagged, and \Draft. Server-supported custom keywords may also be used.

Returns True for success, False for failure.

top
SetFlagAsync (1)
Function ComSetFlagAsync Variant msgId Boolean bUid String flagName Integer value Returns cComChilkatTask

Creates an asynchronous task to call the SetFlag method with the arguments provided.

Returns null on failure

top
SetFlags
Function ComSetFlags cComMessageSet messageSet String flagName Integer value Returns Boolean

Sets or clears one flag for every identifier in the MessageSet supplied in messageSet.

flagName is the flag name, and value is 1 to set it or 0 to clear it. MessageSet.HasUids determines whether the identifiers are UIDs or sequence numbers. Chilkat sends one IMAP STORE or UID STORE command containing the complete identifier set.

IMAP bulk flag changes are not atomic and have no all-or-nothing rollback. Changes applied before a failure remain applied. For UID-based operations, nonexistent UIDs are silently ignored as required by IMAP. For sequence-number operations, an out-of-range sequence number causes the server to return an error; whether valid sequence numbers in the same command were changed before that error is server-dependent.

This method changes server state only. It does not update metadata in any previously fetched Email objects.

Returns True for success, False for failure.

More Information and Examples
top
SetFlagsAsync (1)
Function ComSetFlagsAsync cComMessageSet messageSet String flagName Integer value Returns cComChilkatTask

Creates an asynchronous task to call the SetFlags method with the arguments provided.

Returns null on failure

top
SetMailFlag
Function ComSetMailFlag cComChilkatEmail email String flagName Integer value Returns Boolean

Sets or clears a flag for the server message represented by the Email in email.

Chilkat reads the message identifier from ckx-imap-uid and uses ckx-imap-isUid to determine whether the value is a UID or sequence number. flagName is the flag name, and value is 1 to set it or 0 to clear it. The method fails if the required metadata is absent.

A copied Email can be used as long as the metadata is preserved. When ckx-imap-isUid is NO, the stored value is a sequence number and may no longer identify the same message after an expunge. UID-based emails are preferred for operations performed later or after reconnecting.

Setting \Deleted marks the message for deletion; call Expunge to remove it permanently.

Returns True for success, False for failure.

More Information and Examples
top
SetMailFlagAsync (1)
Function ComSetMailFlagAsync cComChilkatEmail email String flagName Integer value Returns cComChilkatTask

Creates an asynchronous task to call the SetMailFlag method with the arguments provided.

Returns null on failure

top
SetQuota
Function ComSetQuota String quotaRoot String resource Integer quota Returns Boolean
Introduced in version 9.5.0.58

Sends the IMAP SETQUOTA command for quota root quotaRoot.

resource is STORAGE to set the combined message-storage limit or MESSAGE to set the message-count limit. For STORAGE, quota is measured in units of 1024 octets; for example, 500000 represents approximately 500,000,000 bytes.

The server must support the IMAP QUOTA extension and the requested resource type.

More Information and Examples
top
SetQuotaAsync (1)
Function ComSetQuotaAsync String quotaRoot String resource Integer quota Returns cComChilkatTask
Introduced in version 9.5.0.58

Creates an asynchronous task to call the SetQuota method with the arguments provided.

Returns null on failure

top
SetSslClientCert
Function ComSetSslClientCert cComChilkatCert cert Returns Boolean

Specifies the client certificate in cert for TLS client-certificate authentication.

Most IMAP servers do not require a client certificate. When one is required, cert must provide access to the corresponding private key.

Returns True for success, False for failure.

More Information and Examples
top
SetSslClientCertPem
Function ComSetSslClientCertPem String pemDataOrFilename String pemPassword Returns Boolean

Specifies a TLS client certificate and private key from PEM data or a PEM file.

pemDataOrFilename may contain the PEM text itself or a local filesystem path to the PEM file; Chilkat detects which form was supplied. pemPassword contains the password when the private key is encrypted.

Returns True for success, False for failure.

top
SetSslClientCertPfx
Function ComSetSslClientCertPfx String pfxFilename String pfxPassword Returns Boolean

Specifies a TLS client certificate and private key from a PKCS #12/PFX file.

pfxFilename is the local filesystem path of the .pfx or .p12 file, and pfxPassword contains its password.

Returns True for success, False for failure.

top
SshAuthenticatePk
Function ComSshAuthenticatePk String sshLogin cComChilkatSshKey privateKey Returns Boolean

Authenticates the SSH tunnel using the username in sshLogin and the SshKey private key in privateKey.

Call SshOpenTunnel first. The corresponding public key must already be authorized for sshLogin on the SSH server. After authentication, call Connect and Login for the IMAP server.

Returns True for success, False for failure.

top
SshAuthenticatePkAsync (1)
Function ComSshAuthenticatePkAsync String sshLogin cComChilkatSshKey privateKey Returns cComChilkatTask

Creates an asynchronous task to call the SshAuthenticatePk method with the arguments provided.

Returns null on failure

top
SshAuthenticatePw
Function ComSshAuthenticatePw String sshLogin String sshPassword Returns Boolean

Authenticates the SSH tunnel using the username in sshLogin and password in sshPassword.

Call SshOpenTunnel first. After SSH authentication succeeds, call Connect and Login; the IMAP traffic then flows through the tunnel automatically.

Returns True for success, False for failure.

top
SshAuthenticatePwAsync (1)
Function ComSshAuthenticatePwAsync String sshLogin String sshPassword Returns cComChilkatTask

Creates an asynchronous task to call the SshAuthenticatePw method with the arguments provided.

Returns null on failure

top
SshCloseTunnel
Function ComSshCloseTunnel Returns Boolean
Introduced in version 9.5.0.50

Closes the SSH tunnel opened by SshOpenTunnel.

Any IMAP connection using that tunnel must no longer be used after the tunnel is closed.

Returns True for success, False for failure.

More Information and Examples
top
SshCloseTunnelAsync (1)
Function ComSshCloseTunnelAsync Returns cComChilkatTask
Introduced in version 9.5.0.50

Creates an asynchronous task to call the SshCloseTunnel method with the arguments provided.

Returns null on failure

top
SshOpenTunnel
Function ComSshOpenTunnel String sshHostname Integer sshPort Returns Boolean
Introduced in version 9.5.0.50

Connects to the SSH server in sshHostname on port sshPort and prepares an SSH tunnel for the later IMAP connection.

Port 22 is the usual SSH port. After this succeeds, authenticate with SshAuthenticatePw or SshAuthenticatePk, then call Connect and Login for IMAP.

Returns True for success, False for failure.

top
SshOpenTunnelAsync (1)
Function ComSshOpenTunnelAsync String sshHostname Integer sshPort Returns cComChilkatTask
Introduced in version 9.5.0.50

Creates an asynchronous task to call the SshOpenTunnel method with the arguments provided.

Returns null on failure

top
StoreFlags
Function ComStoreFlags Variant msgId Boolean bUid String flagNames Integer value Returns Boolean

Sets or clears multiple flags on one message in the selected mailbox.

If bUid is True, msgId is a UID; otherwise, it is a sequence number. flagNames is a space-separated list such as \Seen \Answered $label1. value is 1 to set all listed flags or 0 to clear them.

The operation uses IMAP STORE or UID STORE and is not transactional. A nonexistent UID can be silently ignored and the command can still succeed. An invalid sequence number causes failure. This method changes server state only and does not update metadata in previously fetched Email objects.

Returns True for success, False for failure.

More Information and Examples
top
StoreFlagsAsync (1)
Function ComStoreFlagsAsync Variant msgId Boolean bUid String flagNames Integer value Returns cComChilkatTask

Creates an asynchronous task to call the StoreFlags method with the arguments provided.

Returns null on failure

top
Subscribe
Function ComSubscribe String mailbox Returns Boolean

Subscribes the authenticated IMAP account to the mailbox named by mailbox.

Subscription controls which mailboxes are returned by subscribed-mailbox listing operations; it does not create the mailbox.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
SubscribeAsync (1)
Function ComSubscribeAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the Subscribe method with the arguments provided.

Returns null on failure

top
Unsubscribe
Function ComUnsubscribe String mailbox Returns Boolean

Removes the subscription to the mailbox named by mailbox.

The mailbox itself and its messages are not deleted.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns True for success, False for failure.

top
UnsubscribeAsync (1)
Function ComUnsubscribeAsync String mailbox Returns cComChilkatTask

Creates an asynchronous task to call the Unsubscribe method with the arguments provided.

Returns null on failure

top
UseCertVault
Function ComUseCertVault cComChilkatXmlCertVault vault Returns Boolean
Introduced in version 9.5.0.40

Associates the XmlCertVault in vault with this Imap object as a source of certificates and private keys for S/MIME operations.

Only one vault can be associated at a time. Calling this method again replaces the previously associated vault.

Returns True for success, False for failure.

More Information and Examples
top
UseSsh
Function ComUseSsh cComChilkatSsh ssh Returns Boolean
Introduced in version 9.5.0.55

Uses an already connected and authenticated Ssh object as the transport for subsequent IMAP connections.

SSH supports multiple logical channels, so the same SSH connection may be shared by IMAP and other Chilkat objects. Call this method before Connect.

Returns True for success, False for failure.

top
UseSshTunnel
Function ComUseSshTunnel cComChilkatSocket tunnel Returns Boolean
Introduced in version 9.5.0.50

Uses the existing SSH tunnel represented by the Socket in tunnel for subsequent IMAP connections.

This allows a tunnel to be shared with other objects. Call this method before Connect.

Returns True for success, False for failure.

top

Deprecated

CheckForNewEmail
Function ComCheckForNewEmail Returns cComMessageSet
This method is deprecated and replaced by QueryMbx

Deprecated: Use QueryMbx instead.

Checks for messages that arrived since the mailbox was selected or since the previous call to this method, whichever is later.

The method closes and reopens the selected mailbox, then searches for messages marked recent or having a UID greater than the prior UIDNEXT. The returned MessageSet contains UIDs and may be passed to FetchMsgSet.

Returns null on failure

top
CheckForNewEmailAsync (1) (2)
Function ComCheckForNewEmailAsync Returns cComChilkatTask
This method is deprecated and replaced by QueryMbx

Creates an asynchronous task to call the CheckForNewEmail method with the arguments provided.

Returns null on failure

top
FetchBundle
Function ComFetchBundle cComMessageSet messageSet Returns cComChilkatEmailBundle
This method is deprecated and replaced by FetchMsgSet

Deprecated: Use FetchMsgSet instead.

Downloads the messages identified by the MessageSet in messageSet and returns them in an EmailBundle.

Whether messageSet contains UIDs or sequence numbers is determined by its HasUids property.

Returns null on failure

top
FetchBundleAsync (1) (2)
Function ComFetchBundleAsync cComMessageSet messageSet Returns cComChilkatTask
This method is deprecated and replaced by FetchMsgSet

Creates an asynchronous task to call the FetchBundle method with the arguments provided.

Returns null on failure

top
FetchBundleAsMime
Function ComFetchBundleAsMime cComMessageSet messageSet Returns cComCkStringArray
This method is deprecated.

Deprecated: Use FetchSingleBd or methods that return Email objects.

Downloads the messages identified by messageSet and returns their MIME sources in a StringArray. MIME may contain binary data and mixed character encodings, so representing it as ordinary strings can require transformations and is not suitable for preserving exact bytes.

Returns null on failure

top
FetchBundleAsMimeAsync (1) (2)
Function ComFetchBundleAsMimeAsync cComMessageSet messageSet Returns cComChilkatTask
This method is deprecated.

Creates an asynchronous task to call the FetchBundleAsMime method with the arguments provided.

Returns null on failure

top
FetchChunk
Function ComFetchChunk Integer startSeqNum Integer count cComMessageSet failedSet cComMessageSet fetchedSet Returns cComChilkatEmailBundle
This method is deprecated and replaced by FetchRange

Deprecated: Use FetchRange instead.

Downloads a sequence-number range beginning at startSeqNum and containing up to count messages.

failedSet receives sequence numbers that could not be fetched, fetchedSet receives sequence numbers fetched successfully, and the returned EmailBundle contains the downloaded messages.

Returns null on failure

top
FetchChunkAsync (1) (2)
Function ComFetchChunkAsync Integer startSeqNum Integer count cComMessageSet failedSet cComMessageSet fetchedSet Returns cComChilkatTask
This method is deprecated and replaced by FetchRange

Creates an asynchronous task to call the FetchChunk method with the arguments provided.

Returns null on failure

top
FetchHeaders
Function ComFetchHeaders cComMessageSet messageSet Returns cComChilkatEmailBundle
This method is deprecated and replaced by FetchMsgSet

Deprecated: Use FetchMsgSet instead.

Downloads only the headers for the messages identified by messageSet and returns them in an EmailBundle.

Use GetMailNumAttach, GetMailAttachSize, GetMailAttachFilename, and GetMailFlag to inspect metadata stored with a header-only email.

Returns null on failure

top
FetchHeadersAsync (1) (2)
Function ComFetchHeadersAsync cComMessageSet messageSet Returns cComChilkatTask
This method is deprecated and replaced by FetchMsgSet

Creates an asynchronous task to call the FetchHeaders method with the arguments provided.

Returns null on failure

top
FetchSequence
Function ComFetchSequence Integer startSeqNum Integer numMessages Returns cComChilkatEmailBundle
This method is deprecated and replaced by FetchRange

Deprecated: Use FetchRange instead.

Downloads numMessages messages beginning with sequence number startSeqNum and returns them in an EmailBundle.

Sequence numbers begin at 1. If the requested count extends beyond the mailbox, messages through the end of the mailbox are returned. Sequence numbers can change whenever messages are expunged.

Returns null on failure

top
FetchSequenceAsync (1) (2)
Function ComFetchSequenceAsync Integer startSeqNum Integer numMessages Returns cComChilkatTask
This method is deprecated and replaced by FetchRange

Creates an asynchronous task to call the FetchSequence method with the arguments provided.

Returns null on failure

top
FetchSequenceAsMime
Function ComFetchSequenceAsMime Integer startSeqNum Integer numMessages Returns cComCkStringArray
This method is deprecated.

Deprecated: Use FetchSingleBd or methods that return Email objects.

Downloads numMessages messages beginning at sequence number startSeqNum and returns each MIME source in a StringArray.

Sequence numbers begin at 1 and may change after an expunge. MIME can contain binary data and mixed encodings, so string-based MIME retrieval is not suitable when exact bytes must be preserved.

Returns null on failure

top
FetchSequenceAsMimeAsync (1) (2)
Function ComFetchSequenceAsMimeAsync Integer startSeqNum Integer numMessages Returns cComChilkatTask
This method is deprecated.

Creates an asynchronous task to call the FetchSequenceAsMime method with the arguments provided.

Returns null on failure

top
FetchSequenceHeaders
Function ComFetchSequenceHeaders Integer startSeqNum Integer numMessages Returns cComChilkatEmailBundle
This method is deprecated and replaced by FetchRange

Deprecated: Use FetchRange instead.

Downloads only the headers for numMessages messages beginning with sequence number startSeqNum.

Sequence numbers begin at 1 and must be within the current range reported by NumMessages. They can change when messages are expunged.

Returns null on failure

top
FetchSequenceHeadersAsync (1) (2)
Function ComFetchSequenceHeadersAsync Integer startSeqNum Integer numMessages Returns cComChilkatTask
This method is deprecated and replaced by FetchRange

Creates an asynchronous task to call the FetchSequenceHeaders method with the arguments provided.

Returns null on failure

top
FetchSingle
Function ComFetchSingle Variant msgId Boolean bUid Returns cComChilkatEmail
This method is deprecated and replaced by FetchEmail

Deprecated: Use FetchEmail instead.

Downloads one message and returns it as an Email. If bUid is True, msgId is a UID; otherwise, msgId is a sequence number.

Ordinary attachment bodies are included according to AutoDownloadAttachments.

Returns null on failure

top
FetchSingleAsync (1) (2)
Function ComFetchSingleAsync Variant msgId Boolean bUid Returns cComChilkatTask
This method is deprecated and replaced by FetchEmail

Creates an asynchronous task to call the FetchSingle method with the arguments provided.

Returns null on failure

top
FetchSingleHeader
Function ComFetchSingleHeader Variant msgId Boolean bUid Returns cComChilkatEmail
This method is deprecated and replaced by FetchEmail

Deprecated: Use FetchEmail instead.

Downloads only the headers for one message. If bUid is True, msgId is a UID; otherwise, msgId is a sequence number.

Use the attachment- and flag-inspection methods to read metadata retained in the header-only Email.

Returns null on failure

top
FetchSingleHeaderAsync (1) (2)
Function ComFetchSingleHeaderAsync Variant msgId Boolean bUid Returns cComChilkatTask
This method is deprecated and replaced by FetchEmail

Creates an asynchronous task to call the FetchSingleHeader method with the arguments provided.

Returns null on failure

top
GetAllUids
Function ComGetAllUids Returns cComMessageSet
This method is deprecated and replaced by QueryMbx

Deprecated: Use QueryMbx instead.

Returns a MessageSet containing every UID in the currently selected mailbox.

The replacement call is equivalent to querying for ALL with UID results requested.

Returns null on failure

top
GetAllUidsAsync (1) (2)
Function ComGetAllUidsAsync Returns cComChilkatTask
This method is deprecated and replaced by QueryMbx

Creates an asynchronous task to call the GetAllUids method with the arguments provided.

Returns null on failure

top
GetSslServerCert
Function ComGetSslServerCert Returns cComChilkatCert
This method is deprecated and replaced by GetServerCert

Deprecated: Use GetServerCert instead.

Returns the certificate presented by the IMAP server for the current TLS connection.

Returns null on failure

top
ListMailboxes
Function ComListMailboxes String reference String wildcardedMailbox Returns cComMailboxes
This method is deprecated and replaced by MbxList

Deprecated: Use MbxList instead.

Sends the IMAP LIST command using reference as the reference name and wildcardedMailbox as the mailbox pattern.

The pattern supports IMAP wildcards: * matches zero or more hierarchy levels, while % matches within one hierarchy level. The returned Mailboxes object contains the matching names and attributes.

This method also updates SeparatorChar from the hierarchy delimiter reported by the server.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns null on failure

top
ListMailboxesAsync (1) (2)
Function ComListMailboxesAsync String reference String wildcardedMailbox Returns cComChilkatTask
This method is deprecated and replaced by MbxList

Creates an asynchronous task to call the ListMailboxes method with the arguments provided.

Returns null on failure

top
ListSubscribed
Function ComListSubscribed String reference String wildcardedMailbox Returns cComMailboxes
This method is deprecated and replaced by MbxList

Deprecated: Use MbxList instead.

Sends the IMAP LSUB command and returns subscribed mailboxes matching wildcardedMailbox, interpreted relative to reference.

The mailbox-pattern rules are the same as for ListMailboxes.

Mailbox names may be supplied as normal Unicode strings. Chilkat automatically handles IMAP modified UTF-7 or UTF-8 mailbox-name encoding as required by the server.

Returns null on failure

top
ListSubscribedAsync (1) (2)
Function ComListSubscribedAsync String reference String wildcardedMailbox Returns cComChilkatTask
This method is deprecated and replaced by MbxList

Creates an asynchronous task to call the ListSubscribed method with the arguments provided.

Returns null on failure

top
Search
Function ComSearch String criteria Boolean bUid Returns cComMessageSet
This method is deprecated and replaced by QueryMbx

Deprecated: Use QueryMbx instead.

Searches the selected mailbox using the IMAP search criteria in criteria. If bUid is True, the returned MessageSet contains UIDs; otherwise, it contains sequence numbers.

criteria is passed to the server as IMAP SEARCH criteria. Multiple keys are combined with AND unless operators such as OR or NOT are used. Common examples include:

  • ALL
  • UNSEEN
  • FROM "sender@example.com"
  • SUBJECT "invoice"
  • SINCE 1-Jul-2026
  • UID 1000:*

String matching is performed by the server and is normally case-insensitive substring matching. SearchCharset controls the charset used for non-ASCII criteria, although some server implementations impose additional restrictions.

Returns null on failure

top
SearchAsync (1) (2)
Function ComSearchAsync String criteria Boolean bUid Returns cComChilkatTask
This method is deprecated and replaced by QueryMbx

Creates an asynchronous task to call the Search method with the arguments provided.

Returns null on failure

top
Sort
Function ComSort String sortCriteria String charset String searchCriteria Boolean bUid Returns cComMessageSet
Introduced in version 9.5.0.76
This method is deprecated and replaced by QueryMbx

Deprecated: Use QueryMbx instead.

Searches the selected mailbox using criteria searchCriteria and returns the matching message identifiers in the order requested by sortCriteria.

sortCriteria is a space-separated sort expression. REVERSE before a key makes that key descending. Supported keys include ARRIVAL, CC, DATE, FROM, SIZE, SUBJECT, and TO.

charset is the search charset. If bUid is True, the returned set contains UIDs; otherwise, sequence numbers are returned. The server must support IMAP SORT.

Returns null on failure

More Information and Examples
top
SortAsync (1) (2)
Function ComSortAsync String sortCriteria String charset String searchCriteria Boolean bUid Returns cComChilkatTask
Introduced in version 9.5.0.76
This method is deprecated and replaced by QueryMbx

Creates an asynchronous task to call the Sort method with the arguments provided.

Returns null on failure

top
ThreadCmd
Function ComThreadCmd String threadAlg String charset String searchCriteria Boolean bUid Returns cComChilkatJsonObject
Introduced in version 9.5.0.77
This method is deprecated and replaced by QueryThread

Deprecated: Use QueryThread instead.

Sends the IMAP THREAD command using threading algorithm threadAlg, charset charset, and search criteria searchCriteria.

Common algorithms are ORDEREDSUBJECT and REFERENCES. If bUid is True, thread members are UIDs; otherwise, they are sequence numbers. The returned JsonObject represents the parent-child thread structure.

The server must advertise the IMAP THREAD capability and support the requested algorithm.

Returns null on failure

top
ThreadCmdAsync (1) (2)
Function ComThreadCmdAsync String threadAlg String charset String searchCriteria Boolean bUid Returns cComChilkatTask
Introduced in version 9.5.0.77
This method is deprecated and replaced by QueryThread

Creates an asynchronous task to call the ThreadCmd method with the arguments provided.

Returns null on failure

top