Class Imap
- All Implemented Interfaces:
AutoCloseable
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.
For an extended overview, see Imap Class Overview.
</section>
Event-capable: long-running methods report progress through a ProgressListener installed
with setProgressListener(ProgressListener), onAbortCheck(BooleanSupplier),
onPercentDone(IntPredicate) or onProgressInfo(BiConsumer).
Instances hold a native Chilkat object: close them with ChilkatObject.close() (try-with-resources) when
done; an unclosed instance is freed when it becomes unreachable.
- See Also:
- Online reference
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddPfxSourceBd(BinData bd, String password)Adds the PKCS #12/PFX data in theBinDatainbdas a source of certificates and private keys for S/MIME processing.voidaddPfxSourceFile(String pfxFilePath, String pfxPassword)Adds a PKCS #12/PFX file that may be searched for certificates and private keys needed for S/MIME decryption or signature processing.voidappendMail(String mailbox, Email email)Appends theEmailinemailto the mailbox named bymailbox.voidappendMime(String mailbox, String mimeText)Appends the complete RFC 822/MIME message inmimeTextto the mailbox named bymailbox.voidappendMimeWithDateStr(String mailbox, String mimeText, String internalDateStr)Appends the MIME message inmimeTextto the mailbox named bymailboxwhile explicitly setting the server-side internal date frominternalDateStr.voidappendMimeWithFlags(String mailbox, String mimeText, boolean seen, boolean flagged, boolean answered, boolean draft)Appends the MIME message inmimeTextto the mailbox named bymailboxand sets its initial system flags.voidappendMimeWithFlagsSb(String mailbox, StringBuilder sbMime, boolean seen, boolean flagged, boolean answered, boolean draft)Appends the MIME contained in theStringBuilderinsbMimeto mailboxmailboxand sets its initial system flags.Sends the IMAPCAPABILITYcommand and returns the server's raw capability response.booleanChecks whether the underlying TCP socket is currently connected to the IMAP server.voidClears the in-memory text returned by.getSessionLog()voidcloseMailbox(String mailbox)Closes the currently selected mailbox while keeping the authenticated IMAP connection open.voidEstablishes a TCP connection to the IMAP server identified bydomainNamebut does not authenticate.voidCopies one message from the currently selected mailbox to the destination mailbox incopyToMailbox.voidcopyMultiple(MessageSet messageSet, String copyToMailbox)Copies the messages identified by theMessageSetinmessageSetfrom the selected mailbox to destination mailboxcopyToMailboxusing one IMAP command.voidcopySequence(int startSeqNum, int count, String copyToMailbox)Copies a contiguous range of messages, identified by sequence number, from the selected mailbox to the destination mailbox incopyToMailbox.voidcreateMailbox(String mailbox)Creates the mailbox named bymailboxon the IMAP server.voiddeleteMailbox(String mailbox)Deletes the mailbox named bymailboxfrom the IMAP server.voidCloses the connection to the IMAP server.voidexamineMailbox(String mailbox)Opens the mailbox inmailboxas read-only.voidexpunge()Permanently removes all messages marked with the\Deletedflag from the currently selected mailbox.voidPermanently removes all messages marked with\Deletedfrom the selected mailbox and then closes the mailbox.voidfetchAttachment(Email emailObject, int attachmentIndex, String saveToPath)Obtains attachmentattachmentIndexfrom theEmailinemailObjectand writes it to the filesystem path insaveToPath.voidfetchAttachmentBd(Email email, int attachmentIndex, BinData binData)Obtains attachmentattachmentIndexfrom theEmailinemailand stores its bytes in theBinDatainbinData.voidfetchAttachmentSb(Email email, int attachmentIndex, String charset, StringBuilder sb)Obtains text attachmentattachmentIndexfrom theEmailinemail, decodes it using the charset incharset, and stores the text in theStringBuilderinsb.fetchAttachmentString(Email emailObject, int attachmentIndex, String charset)Obtains text attachmentattachmentIndexfrom theEmailinemailObjectand decodes its bytes using the character encoding named bycharset.voidfetchChunk2(int seqnum, int count, MessageSet failedSet, MessageSet fetchedSet, EmailBundle bundle)Attempts to downloadcountfull messages beginning with sequence numberseqnum.voidfetchEmail(boolean headerOnly, long msgId, boolean bUid, Email email)Downloads one message or its headers into theEmailinemail.fetchFlags(long msgId, boolean bUid)Returns the space-separated IMAP flags for the message identified bymsgId.voidfetchMsgSet(boolean headersOnly, MessageSet msgSet, EmailBundle bundle)Downloads the existing messages identified by theMessageSetinmsgSetand appends them to theEmailBundleinbundle.voidfetchRange(boolean headersOnly, int seqnum, int count, EmailBundle bundle)Downloadscountmessages beginning with sequence numberseqnumand appends them to theEmailBundleinbundle.fetchSingleAsMime(long msgId, boolean bUid)Downloads one message and returns its MIME source as a string.voidfetchSingleAsMimeSb(long msgId, boolean bUid, StringBuilder sbMime)Downloads one message's MIME into theStringBuilderinsbMime.voidfetchSingleBd(long msgId, boolean bUid, BinData mimeData)Downloads one message's MIME bytes into theBinDatainmimeData.fetchSingleHeaderAsMime(long msgId, boolean bUID)Downloads and returns the MIME header block for one message, without downloading the body.booleanControls cancellation of the method currently running on thisImapobject.booleanControls the initial\Seenflag for these methods:appendMail(String, Email)appendMime(String, String)appendMimeWithDateStr(String, String, String)intContains the UID assigned by the server to the message most recently appended successfully.Selects the IMAP authentication mechanism.Specifies the optional authorization identity used with thePLAINauthentication mechanism.booleanControls whether methods that download a complete email also download ordinary attachment bodies.booleanWhentrue(the default), changes the publicandgetSsl()property values whengetStartTls()is called for a standard IMAP port: Portconnect(String)993: setsSsltotrueandStartTlstofalsefor implicit TLS.Specifies the local IP address to bind when the computer has multiple network interfaces or addresses.Contains the hostname or IP address of the IMAP server to which the object is currently connected.intThe maximum number of seconds to wait while establishing the TCP connection to the IMAP server.Specifies the Windows domain used for NTLM authentication.booleanEnables automatic resolution of credential values from secure operating-system storage.intSets the interval, in milliseconds, betweenevent callbacks during operations that support cancellation.AbortCheckContains theHIGHESTMODSEQvalue of the currently selected mailbox as a decimal string.Specifies the authentication mechanism used by an HTTP proxy.Specifies the optional Windows domain for HTTP-proxy NTLM authentication.Specifies the hostname or numeric IPv4 address of an HTTP proxy through which the IMAP connection is established.Specifies the password used to authenticate with the configured HTTP proxy.intSpecifies the TCP port of the configured HTTP proxy.Specifies the username used to authenticate with the configured HTTP proxy.booleanEnables or disables the in-memory IMAP protocol log.Contains the MIME source sent by the most recent successful call to one of the following methods:appendMail(String, Email)appendMime(String, String)appendMimeWithDateStr(String, String, String)appendMimeWithFlags(String, String, boolean, boolean, boolean, boolean)appendMimeWithFlagsSb(String, StringBuilder, boolean, boolean, boolean, boolean)Contains the most recent raw IMAP command sent to the server.Contains the most recent intermediate response received from the IMAP server while a command was in progress.Contains the raw response most recently received from the IMAP server.Contains the optional IMAP response code from the most recent server response, such asNONEXISTENTorAUTHENTICATIONFAILED.Contains the username of the authenticated IMAP session.getMailAttachFilename(Email email, int attachIndex)Returns the filename for attachmentattachIndexrepresented byemail.intgetMailAttachSize(Email email, int attachIndex)Returns the size in bytes of attachmentattachIndexrepresented byemail.getMailboxStatus(String mailbox)Sends the IMAPSTATUScommand for the mailbox inmailboxand returns the reported values as XML attributes.intgetMailFlag(Email email, String flagName)Returns the state of the flag named byflagNamefrom the IMAP metadata stored in theEmailinemail.intgetMailNumAttach(Email email)Returns the number of ordinary attachments represented byemail.intgetMailSize(Email email)Returns the complete server-reported size of theEmailinemail, in bytes, including attachment data.intContains the number of messages reported when the current mailbox was selected.booleanControls whether fetching full message content marks the message as seen.intSets the scale used byevent callbacks.PercentDoneintgetPort()Specifies the IMAP server port.booleanControls address-family preference when a hostname resolves to both IPv4 and IPv6 addresses.Returns the installed listener, ornull.Sends the IMAPGETQUOTAcommand for the quota root inquotaRootand returns the server response as JSON.getQuotaRoot(String mailboxName)Sends the IMAPGETQUOTAROOTcommand for the mailbox inmailboxNameand returns the server response as JSON.intThe maximum number of seconds that an incoming IMAP response may stall with no additional bytes received.booleanControls verification of the IMAP server's TLS certificate chain.Specifies the IMAPCHARSETused by,Search, andqueryMbx(String, boolean, MessageSet)when search criteria contain non-ASCII characters.queryThread(String, String, boolean, JsonObject)Contains the name of the currently selected or examined mailbox.intSpecifies the application-level buffer size used when sending data through the underlying TCP connection.Contains the mailbox-hierarchy delimiter reported by the IMAP server, typically/or..voidgetServerCert(Cert cert)Stores the certificate presented by the IMAP server for the current or most recent TLS connection in theCertobject supplied ascert.Contains the in-memory log of raw IMAP commands and server responses.Specifies the hostname or numeric IP address of the SOCKS proxy.Specifies the SOCKS5 proxy password.intSpecifies the SOCKS proxy port.Specifies the username sent to a SOCKS4 or SOCKS5 proxy.intSelects whether the IMAP connection uses a SOCKS proxy.intSets the operating system's TCP receive-buffer size.Specifies the sort order used by.queryMbx(String, boolean, MessageSet)intSets the operating system's TCP send-buffer size.booleangetSsl()Controls implicit TLS for the IMAP connection.Restricts the cipher suites and selected TLS security requirements offered for an IMAP TLS connection.Selects the TLS protocol version or minimum version allowed for secure IMAP connections.booleanIndicates whether the IMAP server certificate chain was successfully verified for the current or most recent TLS connection.booleanControls explicit TLS using the IMAPSTARTTLScommand.Contains the cipher suite negotiated for the current or most recent TLS connection, for exampleTLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384.Specifies one or more expected SPKI fingerprints for TLS public-key pinning.Contains the protocol version negotiated for the current or most recent TLS connection, such asTLS 1.2orTLS 1.3.longContains the mailbox's reportedUIDNEXTvalue—the UID expected to be assigned to the next appended message.longContains theUIDVALIDITYvalue of the currently selected mailbox, or0when no mailbox is selected.Provides comma-separated compatibility or platform-specific options for uncommon cases.booleanhasCapability(String name, String capabilityResponse)Tests whether the capability named bynameappears in the raw capability response incapabilityResponse.idleCheck(int timeoutMs)Waits up totimeoutMsmilliseconds for unsolicited mailbox updates afterhas entered IMAP IDLE mode.idleStart()voididleDone()Ends IMAP IDLE mode by sending the protocol'sDONEcontinuation.voidSends the IMAPIDLEcommand and begins listening for unsolicited mailbox updates.booleanReturns the last known connection state without sending data to the IMAP server.booleanIndicates whether this object is in an authenticated IMAP session.voidAuthenticates the connected IMAP session using the login name inloginNameand the credential inpassword.voidloginSecure(SecureString loginName, SecureString password)Authenticates the connected IMAP session using theSecureStringlogin name inloginNameand credential inpassword.voidlogout()Sends the IMAPLOGOUTcommand and ends the authenticated session.voidLists matching mailboxes and appends them to theMailboxesobject inmboxes.voidmoveMessages(MessageSet messageSet, String destFolder)Moves the messages identified by theMessageSetinmessageSetfrom the selected mailbox to destination mailboxdestFolderusing one IMAPMOVEcommand.voidnoop()Sends the IMAPNOOPcommand and waits for the server response.voidonAbortCheck(BooleanSupplier callback)Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it.voidonPercentDone(IntPredicate callback)Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it.voidonProgressInfo(BiConsumer<String,String> callback)Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds.voidqueryMbx(String criteria, boolean bUid, MessageSet msgSet)Searches the selected mailbox using the IMAP criteria incriteriaand stores matching identifiers in theMessageSetinmsgSet.voidqueryThread(String threadAlg, String searchCriteria, boolean bUid, JsonObject json)Sends the IMAPTHREADcommand for the selected mailbox.voidrawCommandBd(BinData bdCmd, BinData bdResp)Sends the raw IMAP command bytes in theBinDatainbdCmdand stores the raw response bytes inbdResp.voidrefetchMailFlags(Email email)Fetches the current IMAP flags for the server message represented byemailand updates itsckx-imap-*metadata headers.voidrenameMailbox(String fromMailbox, String toMailbox)Renames the mailbox infromMailboxto the name intoMailbox.voidselectMailbox(String mailbox)Opens the mailbox inmailboxfor read-write access.sendRawCommand(String cmd)Sends the raw IMAP command text incmdand returns the raw server response.voidsetAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().voidsetAppendSeen(boolean value)Sets theAppendSeenproperty; seegetAppendSeen().voidsetAuthMethod(String value)Sets theAuthMethodproperty; seegetAuthMethod().voidsetAuthzId(String value)Sets theAuthzIdproperty; seegetAuthzId().voidsetAutoDownloadAttachments(boolean value)Sets theAutoDownloadAttachmentsproperty; seegetAutoDownloadAttachments().voidsetAutoFix(boolean value)Sets theAutoFixproperty; seegetAutoFix().voidsetClientIpAddress(String value)Sets theClientIpAddressproperty; seegetClientIpAddress().voidsetConnectTimeout(int value)Sets theConnectTimeoutproperty; seegetConnectTimeout().voidsetDecryptCert(Cert cert)Specifies theCertincertfor decrypting S/MIME messages downloaded by thisImapobject.voidsetDecryptCert2(Cert cert, PrivateKey key)Specifies the certificate incertand its separately suppliedPrivateKeyinkeyfor decrypting S/MIME messages.voidSets theDomainproperty; seegetDomain().voidsetEnableSecrets(boolean value)Sets theEnableSecretsproperty; seegetEnableSecrets().voidSets or clears one flag on the message identified bymsgIdin the selected mailbox.voidsetFlags(MessageSet messageSet, String flagName, int value)Sets or clears one flag for every identifier in theMessageSetsupplied inmessageSet.voidsetHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().voidsetHttpProxyAuthMethod(String value)Sets theHttpProxyAuthMethodproperty; seegetHttpProxyAuthMethod().voidsetHttpProxyDomain(String value)Sets theHttpProxyDomainproperty; seegetHttpProxyDomain().voidsetHttpProxyHostname(String value)Sets theHttpProxyHostnameproperty; seegetHttpProxyHostname().voidsetHttpProxyPassword(String value)Sets theHttpProxyPasswordproperty; seegetHttpProxyPassword().voidsetHttpProxyPort(int value)Sets theHttpProxyPortproperty; seegetHttpProxyPort().voidsetHttpProxyUsername(String value)Sets theHttpProxyUsernameproperty; seegetHttpProxyUsername().voidsetKeepSessionLog(boolean value)Sets theKeepSessionLogproperty; seegetKeepSessionLog().voidsetMailFlag(Email email, String flagName, int value)Sets or clears a flag for the server message represented by theEmailinemail.voidsetPeekMode(boolean value)Sets thePeekModeproperty; seegetPeekMode().voidsetPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().voidsetPort(int value)Sets thePortproperty; seegetPort().voidsetPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().voidsetProgressListener(ProgressListener listener)Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.voidSends the IMAPSETQUOTAcommand for quota rootquotaRoot.voidsetReadTimeout(int value)Sets theReadTimeoutproperty; seegetReadTimeout().voidsetRequireSslCertVerify(boolean value)Sets theRequireSslCertVerifyproperty; seegetRequireSslCertVerify().voidsetSearchCharset(String value)Sets theSearchCharsetproperty; seegetSearchCharset().voidsetSendBufferSize(int value)Sets theSendBufferSizeproperty; seegetSendBufferSize().voidsetSeparatorChar(String value)Sets theSeparatorCharproperty; seegetSeparatorChar().voidsetSocksHostname(String value)Sets theSocksHostnameproperty; seegetSocksHostname().voidsetSocksPassword(String value)Sets theSocksPasswordproperty; seegetSocksPassword().voidsetSocksPort(int value)Sets theSocksPortproperty; seegetSocksPort().voidsetSocksUsername(String value)Sets theSocksUsernameproperty; seegetSocksUsername().voidsetSocksVersion(int value)Sets theSocksVersionproperty; seegetSocksVersion().voidsetSoRcvBuf(int value)Sets theSoRcvBufproperty; seegetSoRcvBuf().voidsetSortCriteria(String value)Sets theSortCriteriaproperty; seegetSortCriteria().voidsetSoSndBuf(int value)Sets theSoSndBufproperty; seegetSoSndBuf().voidsetSsl(boolean value)Sets theSslproperty; seegetSsl().voidsetSslAllowedCiphers(String value)Sets theSslAllowedCiphersproperty; seegetSslAllowedCiphers().voidsetSslClientCert(Cert cert)Specifies the client certificate incertfor TLS client-certificate authentication.voidsetSslClientCertPem(String pemDataOrFilename, String pemPassword)Specifies a TLS client certificate and private key from PEM data or a PEM file.voidsetSslClientCertPfx(String pfxFilename, String pfxPassword)Specifies a TLS client certificate and private key from a PKCS #12/PFX file.voidsetSslProtocol(String value)Sets theSslProtocolproperty; seegetSslProtocol().voidsetStartTls(boolean value)Sets theStartTlsproperty; seegetStartTls().voidsetTlsPinSet(String value)Sets theTlsPinSetproperty; seegetTlsPinSet().voidsetUncommonOptions(String value)Sets theUncommonOptionsproperty; seegetUncommonOptions().voidsshAuthenticatePk(String sshLogin, SshKey privateKey)Authenticates the SSH tunnel using the username insshLoginand theSshKeyprivate key inprivateKey.voidsshAuthenticatePw(String sshLogin, String sshPassword)Authenticates the SSH tunnel using the username insshLoginand password insshPassword.voidCloses the SSH tunnel opened by.sshOpenTunnel(String, int)voidsshOpenTunnel(String sshHostname, int sshPort)Connects to the SSH server insshHostnameon portsshPortand prepares an SSH tunnel for the later IMAP connection.voidstoreFlags(long msgId, boolean bUid, String flagNames, int value)Sets or clears multiple flags on one message in the selected mailbox.voidSubscribes the authenticated IMAP account to the mailbox named bymailbox.voidunsubscribe(String mailbox)Removes the subscription to the mailbox named bymailbox.voiduseCertVault(XmlCertVault vault)Associates theXmlCertVaultinvaultwith thisImapobject as a source of certificates and private keys for S/MIME operations.voidUses an already connected and authenticatedSshobject as the transport for subsequent IMAP connections.voiduseSshTunnel(Socket tunnel)Uses the existing SSH tunnel represented by theSocketintunnelfor subsequent IMAP connections.Methods inherited from class com.chilkatsoft.chilkat2.ChilkatObject
close, getDebugLogFilePath, getLastErrorHtml, getLastErrorText, getLastErrorXml, getLastMethodSuccess, getVerboseLogging, getVersion, isClosed, setDebugLogFilePath, setLastMethodSuccess, setVerboseLogging, toString
-
Constructor Details
-
Imap
public Imap()Creates a newImapobject.
-
-
Method Details
-
getAbortCurrent
public boolean getAbortCurrent()Controls cancellation of the method currently running on thisImapobject.- Set this property to
trueto 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
falsewhen 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.
- Returns:
- the value of the
AbortCurrentproperty
- Set this property to
-
setAbortCurrent
public void setAbortCurrent(boolean value)Sets theAbortCurrentproperty; seegetAbortCurrent().- Parameters:
value- the new value
-
getAppendSeen
public boolean getAppendSeen()Controls the initial\Seenflag 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.
- Returns:
- the value of the
AppendSeenproperty
-
setAppendSeen
public void setAppendSeen(boolean value)Sets theAppendSeenproperty; seegetAppendSeen().- Parameters:
value- the new value
-
getAppendUid
public int getAppendUid()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 to0if the server succeeds but does not report an appended UID. A failed append leaves the previous value unchanged.- Returns:
- the value of the
AppendUidproperty (read-only)
-
getAuthMethod
Selects the IMAP authentication mechanism. Matching is case-insensitive, but spelling matters.Value Purpose
LOGINUsername and password authentication.PLAINSASL PLAIN authentication.may also be used.getAuthzId()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.DefaultNtlmVersionto1and retry.- Returns:
- the value of the
AuthMethodproperty
-
setAuthMethod
Sets theAuthMethodproperty; seegetAuthMethod().- Parameters:
value- the new value (notnull)
-
getAuthzId
Specifies the optional authorization identity used with thePLAINauthentication mechanism.Leave this property empty unless the IMAP server requires an authorization identity that differs from the login identity supplied to
.login(String, String)- Returns:
- the value of the
AuthzIdproperty
-
setAuthzId
Sets theAuthzIdproperty; seegetAuthzId().- Parameters:
value- the new value (notnull)
-
getAutoDownloadAttachments
public boolean getAutoDownloadAttachments()Controls whether methods that download a complete email also download ordinary attachment bodies. The default istrue.true: complete-email fetches include attachment bodies.false: complete-email fetches omit ordinary attachment bodies, whether the result is returned as anEmailobject or as MIME.
Header-only methods never download attachment bodies. They add
ckx-imap-*metadata describing the attachments, which can be read with,getMailNumAttach(Email), andgetMailAttachFilename(Email, int). In this state, thegetMailAttachSize(Email, int)Emailobject's ordinary attachment count can still be0.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.
- Returns:
- the value of the
AutoDownloadAttachmentsproperty
-
setAutoDownloadAttachments
public void setAutoDownloadAttachments(boolean value)Sets theAutoDownloadAttachmentsproperty; seegetAutoDownloadAttachments().- Parameters:
value- the new value
-
getAutoFix
public boolean getAutoFix()Whentrue(the default), changes the publicandgetSsl()property values whengetStartTls()is called for a standard IMAP port:connect(String)- Port
993: setsSsltotrueandStartTlstofalsefor implicit TLS. - Port
143: setsSsltofalse. The existingStartTlsvalue determines whether the connection is upgraded explicitly.
For a nonstandard port, this property makes no changes. Set it to
falsewhen the application must preserve an unusual port and TLS combination exactly as configured.- Returns:
- the value of the
AutoFixproperty
- Port
-
setAutoFix
public void setAutoFix(boolean value)Sets theAutoFixproperty; seegetAutoFix().- Parameters:
value- the new value
-
getClientIpAddress
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.- Returns:
- the value of the
ClientIpAddressproperty
-
setClientIpAddress
Sets theClientIpAddressproperty; seegetClientIpAddress().- Parameters:
value- the new value (notnull)
-
getConnectTimeout
public int getConnectTimeout()The maximum number of seconds to wait while establishing the TCP connection to the IMAP server.The default is
30seconds. This timeout applies to connection establishment, not to later reads from the server.- Returns:
- the value of the
ConnectTimeoutproperty
-
setConnectTimeout
public void setConnectTimeout(int value)Sets theConnectTimeoutproperty; seegetConnectTimeout().- Parameters:
value- the new value
-
getConnectedToHost
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.
- Returns:
- the value of the
ConnectedToHostproperty (read-only)
-
getDomain
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.
- Returns:
- the value of the
Domainproperty
-
setDomain
Sets theDomainproperty; seegetDomain().- Parameters:
value- the new value (notnull)
-
getEnableSecrets
public boolean getEnableSecrets()Enables automatic resolution of credential values from secure operating-system storage. The default isfalse.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
,getHttpProxyPassword(), the password supplied togetSocksPassword(), and the password supplied tologin(String, String).sshAuthenticatePw(String, String)- Returns:
- the value of the
EnableSecretsproperty
-
setEnableSecrets
public void setEnableSecrets(boolean value)Sets theEnableSecretsproperty; seegetEnableSecrets().- Parameters:
value- the new value
-
getHeartbeatMs
public int getHeartbeatMs()Sets the interval, in milliseconds, betweenevent callbacks during operations that support cancellation.AbortCheckThe default is
0, which disables periodiccallbacks.AbortCheck- Returns:
- the value of the
HeartbeatMsproperty
-
setHeartbeatMs
public void setHeartbeatMs(int value)Sets theHeartbeatMsproperty; seegetHeartbeatMs().- Parameters:
value- the new value
-
getHighestModSeq
Contains theHIGHESTMODSEQvalue of the currently selected mailbox as a decimal string.The value is
0when 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.- Returns:
- the value of the
HighestModSeqproperty (read-only)
-
getHttpProxyAuthMethod
Specifies the authentication mechanism used by an HTTP proxy.Valid values are
BasicandNTLM. This property is used only whenidentifies an HTTP proxy that requires authentication.getHttpProxyHostname()- Returns:
- the value of the
HttpProxyAuthMethodproperty
-
setHttpProxyAuthMethod
Sets theHttpProxyAuthMethodproperty; seegetHttpProxyAuthMethod().- Parameters:
value- the new value (notnull)
-
getHttpProxyDomain
Specifies the optional Windows domain for HTTP-proxy NTLM authentication.It is ignored when the proxy does not use NTLM authentication.
- Returns:
- the value of the
HttpProxyDomainproperty
-
setHttpProxyDomain
Sets theHttpProxyDomainproperty; seegetHttpProxyDomain().- Parameters:
value- the new value (notnull)
-
getHttpProxyHostname
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.
- Returns:
- the value of the
HttpProxyHostnameproperty
-
setHttpProxyHostname
Sets theHttpProxyHostnameproperty; seegetHttpProxyHostname().- Parameters:
value- the new value (notnull)
-
getHttpProxyPassword
Specifies the password used to authenticate with the configured HTTP proxy.It is used only when the proxy requires authentication.
- Returns:
- the value of the
HttpProxyPasswordproperty
-
setHttpProxyPassword
Sets theHttpProxyPasswordproperty; seegetHttpProxyPassword().- Parameters:
value- the new value (notnull)
-
getHttpProxyPort
public int getHttpProxyPort()Specifies the TCP port of the configured HTTP proxy.Common values include
8080and3128, but the correct value is determined by the proxy server configuration.- Returns:
- the value of the
HttpProxyPortproperty
-
setHttpProxyPort
public void setHttpProxyPort(int value)Sets theHttpProxyPortproperty; seegetHttpProxyPort().- Parameters:
value- the new value
-
getHttpProxyUsername
Specifies the username used to authenticate with the configured HTTP proxy.It is used only when the proxy requires authentication.
- Returns:
- the value of the
HttpProxyUsernameproperty
-
setHttpProxyUsername
Sets theHttpProxyUsernameproperty; seegetHttpProxyUsername().- Parameters:
value- the new value (notnull)
-
getKeepSessionLog
public boolean getKeepSessionLog()Enables or disables the in-memory IMAP protocol log. The default isfalse.When enabled,
contains the raw commands sent to the server and the raw responses received. UsegetSessionLog()to reset it.clearSessionLog()- Returns:
- the value of the
KeepSessionLogproperty
-
setKeepSessionLog
public void setKeepSessionLog(boolean value)Sets theKeepSessionLogproperty; seegetKeepSessionLog().- Parameters:
value- the new value
-
getLastAppendedMime
Contains the MIME source sent by the most recent successful call to one of the following methods:appendMail(String, Email)appendMime(String, String)appendMimeWithDateStr(String, String, String)appendMimeWithFlags(String, String, boolean, boolean, boolean, boolean)appendMimeWithFlagsSb(String, StringBuilder, boolean, boolean, boolean, boolean)
A failed append leaves the previous value unchanged. Therefore, read this property only after confirming that the append method succeeded.
- Returns:
- the value of the
LastAppendedMimeproperty (read-only)
-
getLastCommand
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.
- Returns:
- the value of the
LastCommandproperty (read-only)
-
getLastIntermediateResponse
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.
- Returns:
- the value of the
LastIntermediateResponseproperty (read-only)
-
getLastResponse
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 successfulFETCHreturns no matching message. Use the method return value orLastMethodSuccessas the authoritative success indicator.- Returns:
- the value of the
LastResponseproperty (read-only)
-
getLastResponseCode
Contains the optional IMAP response code from the most recent server response, such asNONEXISTENTorAUTHENTICATIONFAILED. 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
LastMethodSuccessto determine whether the current operation succeeded.- Returns:
- the value of the
LastResponseCodeproperty (read-only)
-
getLoggedInUser
Contains the username of the authenticated IMAP session.Returns an empty string when the object is not logged in.
- Returns:
- the value of the
LoggedInUserproperty (read-only)
-
getNumMessages
public int getNumMessages()Contains the number of messages reported when the current mailbox was selected.The value is updated by
andselectMailbox(String). UnsolicitedexamineMailbox(String)EXISTSnotifications returned bydo not automatically update this property; use the notification value or reselect/query the mailbox when a refreshed count is needed.idleCheck(int)- Returns:
- the value of the
NumMessagesproperty (read-only)
-
getPeekMode
public boolean getPeekMode()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\Seenflag.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.- Returns:
- the value of the
PeekModeproperty
-
setPeekMode
public void setPeekMode(boolean value)Sets thePeekModeproperty; seegetPeekMode().- Parameters:
value- the new value
-
getPercentDoneScale
public int getPercentDoneScale()Sets the scale used byevent callbacks. The default isPercentDone100.For example, a scale of
1000gives tenths-of-a-percent precision, so a callback value of453represents 45.3% complete. Values are limited to the range10through100000.This property applies only to languages and environments that support event callbacks and only to operations for which progress can be measured.
- Returns:
- the value of the
PercentDoneScaleproperty
-
setPercentDoneScale
public void setPercentDoneScale(int value)Sets thePercentDoneScaleproperty; seegetPercentDoneScale().- Parameters:
value- the new value
-
getPort
public int getPort()Specifies the IMAP server port. The default is143.993is the standard port for implicit TLS and is normally used withset togetSsl()true.143is the standard port for ordinary IMAP and for explicit TLS requested with.getStartTls()
When
is enabled, standard port values are used to adjust the effective TLS configuration when connecting.getAutoFix()- Returns:
- the value of the
Portproperty
-
setPort
public void setPort(int value)Sets thePortproperty; seegetPort().- Parameters:
value- the new value
-
getPreferIpv6
public boolean getPreferIpv6()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.
- Returns:
- the value of the
PreferIpv6property
-
setPreferIpv6
public void setPreferIpv6(boolean value)Sets thePreferIpv6property; seegetPreferIpv6().- Parameters:
value- the new value
-
getReadTimeout
public int getReadTimeout()The maximum number of seconds that an incoming IMAP response may stall with no additional bytes received.The default is
60seconds. This is an inactivity timeout, not a limit on the total time allowed for a large response.- Returns:
- the value of the
ReadTimeoutproperty
-
setReadTimeout
public void setReadTimeout(int value)Sets theReadTimeoutproperty; seegetReadTimeout().- Parameters:
value- the new value
-
getRequireSslCertVerify
public boolean getRequireSslCertVerify()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.supplements rather than replaces normal certificate verification.getTlsPinSet()The hostname used for the TLS connection is also used for Server Name Indication (SNI) and certificate hostname comparison.
- Returns:
- the value of the
RequireSslCertVerifyproperty
-
setRequireSslCertVerify
public void setRequireSslCertVerify(boolean value)Sets theRequireSslCertVerifyproperty; seegetRequireSslCertVerify().- Parameters:
value- the new value
-
getSearchCharset
Specifies the IMAPCHARSETused by,Search, andqueryMbx(String, boolean, MessageSet)when search criteria contain non-ASCII characters. The default isqueryThread(String, String, boolean, JsonObject)UTF-8.If the criteria contain only 7-bit ASCII characters, no
CHARSETis needed and this property has no effect. The valueAUTOenables 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.
- Returns:
- the value of the
SearchCharsetproperty
-
setSearchCharset
Sets theSearchCharsetproperty; seegetSearchCharset().- Parameters:
value- the new value (notnull)
-
getSelectedMailbox
Contains the name of the currently selected or examined mailbox.Returns an empty string when no mailbox is selected.
- Returns:
- the value of the
SelectedMailboxproperty (read-only)
-
getSendBufferSize
public int getSendBufferSize()Specifies the application-level buffer size used when sending data through the underlying TCP connection.The default is
32767bytes. Most applications should leave this setting unchanged.- Returns:
- the value of the
SendBufferSizeproperty
-
setSendBufferSize
public void setSendBufferSize(int value)Sets theSendBufferSizeproperty; seegetSendBufferSize().- Parameters:
value- the new value
-
getSeparatorChar
Contains the mailbox-hierarchy delimiter reported by the IMAP server, typically/or..and the legacy mailbox-listing methods update this property from the server's LIST response. The value is a string containing one character.mbxList(boolean, String, String, Mailboxes)- Returns:
- the value of the
SeparatorCharproperty
-
setSeparatorChar
Sets theSeparatorCharproperty; seegetSeparatorChar().- Parameters:
value- the new value (notnull)
-
getSessionLog
Contains the in-memory log of raw IMAP commands and server responses.must begetKeepSessionLog()truefor logging to occur. Callto remove previously collected entries.clearSessionLog()Chilkat redacts sensitive credentials, including passwords and OAuth access tokens, from session logs, diagnostic logs, and
LastErrorText.- Returns:
- the value of the
SessionLogproperty (read-only)
-
getSoRcvBuf
public int getSoRcvBuf()Sets the operating system's TCP receive-buffer size. The default is4194304bytes.Most applications should leave this unchanged. Increasing it may improve download throughput on high-latency or high-bandwidth networks. Values that are multiples of
4096are recommended.- Returns:
- the value of the
SoRcvBufproperty
-
setSoRcvBuf
public void setSoRcvBuf(int value)Sets theSoRcvBufproperty; seegetSoRcvBuf().- Parameters:
value- the new value
-
getSoSndBuf
public int getSoSndBuf()Sets the operating system's TCP send-buffer size. The default is262144bytes.Most applications should leave this unchanged. Increasing it may improve upload throughput; values such as
524288or1048576may be tested when needed.- Returns:
- the value of the
SoSndBufproperty
-
setSoSndBuf
public void setSoSndBuf(int value)Sets theSoSndBufproperty; seegetSoSndBuf().- Parameters:
value- the new value
-
getSocksHostname
Specifies the hostname or numeric IP address of the SOCKS proxy.This property is used only when
isgetSocksVersion()4or5.- Returns:
- the value of the
SocksHostnameproperty
-
setSocksHostname
Sets theSocksHostnameproperty; seegetSocksHostname().- Parameters:
value- the new value (notnull)
-
getSocksPassword
Specifies the SOCKS5 proxy password.It is ignored for SOCKS4 because SOCKS4 does not define password authentication.
- Returns:
- the value of the
SocksPasswordproperty
-
setSocksPassword
Sets theSocksPasswordproperty; seegetSocksPassword().- Parameters:
value- the new value (notnull)
-
getSocksPort
public int getSocksPort()Specifies the SOCKS proxy port. The default is1080.This property is used only when
isgetSocksVersion()4or5.- Returns:
- the value of the
SocksPortproperty
-
setSocksPort
public void setSocksPort(int value)Sets theSocksPortproperty; seegetSocksPort().- Parameters:
value- the new value
-
getSocksUsername
Specifies the username sent to a SOCKS4 or SOCKS5 proxy.This property is used only when
isgetSocksVersion()4or5.- Returns:
- the value of the
SocksUsernameproperty
-
setSocksUsername
Sets theSocksUsernameproperty; seegetSocksUsername().- Parameters:
value- the new value (notnull)
-
getSocksVersion
public int getSocksVersion()Selects whether the IMAP connection uses a SOCKS proxy.Value Behavior
0Do not use a SOCKS proxy. This is the default.4Connect through a SOCKS4 proxy.5Connect through a SOCKS5 proxy.- Returns:
- the value of the
SocksVersionproperty
-
setSocksVersion
public void setSocksVersion(int value)Sets theSocksVersionproperty; seegetSocksVersion().- Parameters:
value- the new value
-
getSortCriteria
Specifies the sort order used by. The default is the empty string, which uses an ordinary IMAPqueryMbx(String, boolean, MessageSet)SEARCH.Set this property to a space-separated list of sort keys. Sorting is ascending unless
REVERSEprecedes a key. Supported keys areARRIVAL,CC,DATE,FROM,SIZE,SUBJECT, andTO.Examples:
SUBJECT REVERSE DATEREVERSE SIZEARRIVAL
If the server does not support the IMAP
SORTextension, Chilkat automatically falls back to an ordinarySEARCH.- Returns:
- the value of the
SortCriteriaproperty
-
setSortCriteria
Sets theSortCriteriaproperty; seegetSortCriteria().- Parameters:
value- the new value (notnull)
-
getSsl
public boolean getSsl()Controls implicit TLS for the IMAP connection. The default isfalse.true: begin the connection with a TLS handshake, typically on port993.false: begin with ordinary IMAP. Usewhen the server requires an explicit STARTTLS upgrade.getStartTls()
If both this property and
aregetStartTls()true, implicit TLS takes precedence and STARTTLS is not used.- Returns:
- the value of the
Sslproperty
-
setSsl
public void setSsl(boolean value)Sets theSslproperty; seegetSsl().- Parameters:
value- the new value
-
getSslAllowedCiphers
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:
rsa1024orrsa2048to require a minimum RSA server-key size.secure-renegotiationto require secure TLS renegotiation.best-practicesto use the security policy recommended by the installed Chilkat version.
Legacy keywords such as
aes256-cbc,aes128-cbc,3des-cbc, andrc4remain recognized for compatibility, but explicitly listing acceptable suites is preferred.- Returns:
- the value of the
SslAllowedCiphersproperty
-
setSslAllowedCiphers
Sets theSslAllowedCiphersproperty; seegetSslAllowedCiphers().- Parameters:
value- the new value (notnull)
-
getSslProtocol
Selects the TLS protocol version or minimum version allowed for secure IMAP connections.The complete list of accepted values is:
defaultTLS 1.3TLS 1.2TLS 1.1TLS 1.0SSL 3.0TLS 1.3 or higherTLS 1.2 or higherTLS 1.1 or higherTLS 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.- Returns:
- the value of the
SslProtocolproperty
-
setSslProtocol
Sets theSslProtocolproperty; seegetSslProtocol().- Parameters:
value- the new value (notnull)
-
getSslServerCertVerified
public boolean getSslServerCertVerified()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.
- Returns:
- the value of the
SslServerCertVerifiedproperty (read-only)
-
getStartTls
public boolean getStartTls()Controls explicit TLS using the IMAPSTARTTLScommand. The default isfalse.true: connect in clear text, issueSTARTTLS, 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, settogetSsl()trueand normally use port993. If both properties aretrue,takes precedence.getSsl()- Returns:
- the value of the
StartTlsproperty
-
setStartTls
public void setStartTls(boolean value)Sets theStartTlsproperty; seegetStartTls().- Parameters:
value- the new value
-
getTlsCipherSuite
Contains the cipher suite negotiated for the current or most recent TLS connection, for exampleTLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384.The value is empty before a TLS connection has been established or after a failed TLS negotiation.
- Returns:
- the value of the
TlsCipherSuiteproperty (read-only)
-
getTlsPinSet
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
isgetRequireSslCertVerify()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, andripemd320. Supported encodings includebase64,hex, and other Chilkat-supported binary encodings.- Returns:
- the value of the
TlsPinSetproperty
-
setTlsPinSet
Sets theTlsPinSetproperty; seegetTlsPinSet().- Parameters:
value- the new value (notnull)
-
getTlsVersion
Contains the protocol version negotiated for the current or most recent TLS connection, such asTLS 1.2orTLS 1.3.The value is empty before a TLS connection has been established or after a failed TLS negotiation.
- Returns:
- the value of the
TlsVersionproperty (read-only)
-
getUidNext
public long getUidNext()Contains the mailbox's reportedUIDNEXTvalue—the UID expected to be assigned to the next appended message.The value is
0when no mailbox is selected or when the server did not provideUIDNEXT.- Returns:
- the value of the
UidNextproperty (read-only)
-
getUidValidity
public long getUidValidity()Contains theUIDVALIDITYvalue of the currently selected mailbox, or0when no mailbox is selected.An application that stores message UIDs should also store this value. If
UIDVALIDITYchanges in a later session, previously stored UIDs must no longer be assumed to identify the same messages.- Returns:
- the value of the
UidValidityproperty (read-only)
-
getUncommonOptions
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.
- Returns:
- the value of the
UncommonOptionsproperty
-
setUncommonOptions
Sets theUncommonOptionsproperty; seegetUncommonOptions().- Parameters:
value- the new value (notnull)
-
addPfxSourceBd
Adds the PKCS #12/PFX data in theBinDatainbdas a source of certificates and private keys for S/MIME processing.passwordcontains the PFX password. Call this method once for each additional source.- Parameters:
bd- thebdargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
addPfxSourceFile
Adds a PKCS #12/PFX file that may be searched for certificates and private keys needed for S/MIME decryption or signature processing.pfxFilePathis the local filesystem path of the PFX file, andpfxPasswordcontains 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.
- Parameters:
pfxFilePath- thepfxFilePathargument (notnull)pfxPassword- thepfxPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendMail
Appends theEmailinemailto the mailbox named bymailbox.controls the initialgetAppendSeen()\Seenflag. After success,contains the UID reported by the server, orgetAppendUid()0if no UID was reported, andcontains the MIME sent.getLastAppendedMime()Rendering for the append does not generate or replace
email'sDate,Message-ID, or MIME boundary values. Ifemailuses an8bitorbinarytransfer 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.
- Parameters:
mailbox- themailboxargument (notnull)email- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendMime
Appends the complete RFC 822/MIME message inmimeTextto the mailbox named bymailbox.controls the initialgetAppendSeen()\Seenflag. After success,contains the UID reported by the server, orgetAppendUid()0if no UID was reported, andcontains the MIME sent.getLastAppendedMime()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.
- Parameters:
mailbox- themailboxargument (notnull)mimeText- themimeTextargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendMimeWithDateStr
Appends the MIME message inmimeTextto the mailbox named bymailboxwhile explicitly setting the server-side internal date frominternalDateStr.internalDateStris an RFC 822 date/time string, for exampleFri, 10 Jul 2026 20:15:30 GMT. The internal date is mailbox metadata and is distinct from the message'sDateheader.controls the initialgetAppendSeen()\Seenflag.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.
- Parameters:
mailbox- themailboxargument (notnull)mimeText- themimeTextargument (notnull)internalDateStr- theinternalDateStrargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendMimeWithFlags
public void appendMimeWithFlags(String mailbox, String mimeText, boolean seen, boolean flagged, boolean answered, boolean draft)Appends the MIME message inmimeTextto the mailbox named bymailboxand sets its initial system flags.seencontrols\Seen.flaggedcontrols\Flagged.answeredcontrols\Answered.draftcontrols\Draft.
Use
trueto set a flag andfalseto leave it unset. The explicit flag arguments are used instead of.getAppendSeen()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.
- Parameters:
mailbox- themailboxargument (notnull)mimeText- themimeTextargument (notnull)seen- theseenargumentflagged- theflaggedargumentanswered- theansweredargumentdraft- thedraftargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
appendMimeWithFlagsSb
public void appendMimeWithFlagsSb(String mailbox, StringBuilder sbMime, boolean seen, boolean flagged, boolean answered, boolean draft)Appends the MIME contained in theStringBuilderinsbMimeto mailboxmailboxand sets its initial system flags.seencontrols\Seen.flaggedcontrols\Flagged.answeredcontrols\Answered.draftcontrols\Draft.
The explicit flag arguments are used instead of
.getAppendSeen()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.
- Parameters:
mailbox- themailboxargument (notnull)sbMime- thesbMimeargument (notnull)seen- theseenargumentflagged- theflaggedargumentanswered- theansweredargumentdraft- thedraftargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
capability
Sends the IMAPCAPABILITYcommand and returns the server's raw capability response.Use
to test the returned text for a particular capability such ashasCapability(String, String)IDLE,MOVE,SORT, orQUOTA.- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
checkConnection
public boolean checkConnection()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()- Returns:
- the result; this method never throws
ChilkatException
-
clearSessionLog
public void clearSessionLog()Clears the in-memory text returned by.getSessionLog()Session logging remains enabled or disabled according to
.getKeepSessionLog() -
closeMailbox
Closes the currently selected mailbox while keeping the authenticated IMAP connection open.mailboxis retained for backward compatibility but is ignored. It may be the empty string. Messages marked with\Deletedare permanently removed as part of the close operation. After success,is empty, but another mailbox can be selected on the same connection.getSelectedMailbox()- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
connect
Establishes a TCP connection to the IMAP server identified bydomainNamebut does not authenticate.domainNamemay be a hostname, IPv4 address, or IPv6 address. Configure,getPort(),getSsl(), proxy settings, and timeouts before calling this method. The TLS hostname is used for Server Name Indication (SNI) and certificate hostname comparison. CallgetStartTls()after the connection succeeds.login(String, String)If this method is called while already connected, Chilkat tears down the existing connection and establishes a new connection to
domainName. This applies even whendomainNamenames 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.
- Parameters:
domainName- thedomainNameargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
copy
Copies one message from the currently selected mailbox to the destination mailbox incopyToMailbox.msgIdidentifies the source message. IfbUidistrue,msgIdis a UID; otherwise,msgIdis 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.
- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentcopyToMailbox- thecopyToMailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
copyMultiple
Copies the messages identified by theMessageSetinmessageSetfrom the selected mailbox to destination mailboxcopyToMailboxusing one IMAP command.MessageSet.HasUidsdetermines whethermessageSetcontains 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.
- Parameters:
messageSet- themessageSetargument (notnull)copyToMailbox- thecopyToMailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
copySequence
Copies a contiguous range of messages, identified by sequence number, from the selected mailbox to the destination mailbox incopyToMailbox.startSeqNumis the first sequence number andcountis the number of messages to copy. IMAP sequence numbers begin at1and 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.
- Parameters:
startSeqNum- thestartSeqNumargumentcount- thecountargumentcopyToMailbox- thecopyToMailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
createMailbox
Creates the mailbox named bymailboxon the IMAP server.Use the hierarchy delimiter reported in
when creating a nested mailbox. In IMAP terminology, mailbox and folder are synonymous.getSeparatorChar()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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
deleteMailbox
Deletes the mailbox named bymailboxfrom 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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
disconnect
public void disconnect()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.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
examineMailbox
Opens the mailbox inmailboxas read-only.Use this instead of
when the application must not change message flags or mailbox state. Successful examination updates properties such asselectMailbox(String),getNumMessages(), andgetUidValidity().getUidNext()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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
expunge
public void expunge()Permanently removes all messages marked with the\Deletedflag from the currently selected mailbox.The mailbox remains selected and the authenticated connection remains open. Expunging can change sequence numbers for the remaining messages.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
expungeAndClose
public void expungeAndClose()Permanently removes all messages marked with\Deletedfrom the selected mailbox and then closes the mailbox.After success,
is empty. The authenticated IMAP connection remains open and can be used to select another mailbox.getSelectedMailbox()- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchAttachment
Obtains attachmentattachmentIndexfrom theEmailinemailObjectand writes it to the filesystem path insaveToPath. Attachment indexes are zero-based.saveToPathmay 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
emailObjectalready contains the attachment bytes, the data is saved without contacting the IMAP server. IfemailObjectwas fetched without attachment bodies, Chilkat uses itsckx-imap-*metadata to locate and download the requested MIME part. The same IMAP session is not required, and a copiedEmailcan be used if the metadata is preserved.The corresponding mailbox must be selected when a server fetch is required. If
ckx-imap-isUidisYES, the permanent UID is used and the operation can work after reconnecting. If it isNO, 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.
- Parameters:
emailObject- theemailObjectargument (notnull)attachmentIndex- theattachmentIndexargumentsaveToPath- thesaveToPathargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchAttachmentBd
Obtains attachmentattachmentIndexfrom theEmailinemailand stores its bytes in theBinDatainbinData.Attachment indexes are zero-based.
binDatais always cleared first. On success it contains the complete attachment bytes; on failure it remains empty.See
for details about downloading attachment data not already present infetchAttachment(Email, int, String)email.- Parameters:
email- theemailargument (notnull)attachmentIndex- theattachmentIndexargumentbinData- thebinDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchAttachmentSb
Obtains text attachmentattachmentIndexfrom theEmailinemail, decodes it using the charset incharset, and stores the text in theStringBuilderinsb.Attachment indexes are zero-based.
sbis 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
for details about downloading data not already present infetchAttachment(Email, int, String)email.- Parameters:
email- theemailargument (notnull)attachmentIndex- theattachmentIndexargumentcharset- thecharsetargument (notnull)sb- thesbargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchAttachmentString
Obtains text attachmentattachmentIndexfrom theEmailinemailObjectand decodes its bytes using the character encoding named bycharset.Use this only when the attachment contains text. Attachment indexes are zero-based. See
for information about downloading attachment data that is not already present infetchAttachment(Email, int, String)emailObject.- Parameters:
emailObject- theemailObjectargument (notnull)attachmentIndex- theattachmentIndexargumentcharset- thecharsetargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchChunk2
public void fetchChunk2(int seqnum, int count, MessageSet failedSet, MessageSet fetchedSet, EmailBundle bundle)Attempts to downloadcountfull messages beginning with sequence numberseqnum.failedSetandfetchedSetare cleared before use.failedSetreceives sequence numbers that failed or were not yet fetched,fetchedSetreceives sequence numbers fetched successfully, and both sets haveMessageSet.HasUidsset tofalse. Downloaded messages are appended to theEmailBundleinbundle, which is not cleared.Sequence numbers beyond the end of the mailbox are added to
failedSet. The method can return success even whenfailedSetis 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,fetchedSetretains the successfully fetched sequence numbers, andfailedSetcontains the failed and not-yet-fetched sequence numbers. Processing stops and the connection must be considered unusable.- Parameters:
seqnum- theseqnumargumentcount- thecountargumentfailedSet- thefailedSetargument (notnull)fetchedSet- thefetchedSetargument (notnull)bundle- thebundleargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchEmail
Downloads one message or its headers into theEmailinemail.headerOnly=true: download headers only.headerOnly=false: download the full message.bUid=true:msgIdis a UID.bUid=false:msgIdis a sequence number.
On success,
emailis replaced with the fetched email. On failure,emailremains 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.getAutoDownloadAttachments()controls whether a full fetch setsgetPeekMode()\Seen; a header-only fetch does not set it.- Parameters:
headerOnly- theheaderOnlyargumentmsgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentemail- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchFlags
Returns the space-separated IMAP flags for the message identified bymsgId.If
bUidistrue,msgIdis 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.
- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchMsgSet
Downloads the existing messages identified by theMessageSetinmsgSetand appends them to theEmailBundleinbundle.bundleis not cleared.headersOnly=true: download headers only.headersOnly=false: download full messages, with ordinary attachments controlled by.getAutoDownloadAttachments()
MessageSet.HasUidsdetermines whethermsgSetcontains UIDs or sequence numbers. AMessageSetis 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.- Parameters:
headersOnly- theheadersOnlyargumentmsgSet- themsgSetargument (notnull)bundle- thebundleargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchRange
Downloadscountmessages beginning with sequence numberseqnumand appends them to theEmailBundleinbundle.bundleis not cleared.headersOnly=true: download headers only.headersOnly=false: download full messages, with ordinary attachments controlled by.getAutoDownloadAttachments()
seqnumandcountmust both be greater than0. IMAP sequence numbers begin at1; passing0forseqnum,0forcount, or a negative count fails without changingbundle. 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.- Parameters:
headersOnly- theheadersOnlyargumentseqnum- theseqnumargumentcount- thecountargumentbundle- thebundleargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchSingleAsMime
Downloads one message and returns its MIME source as a string.If
bUidistrue,msgIdis a UID; otherwise,msgIdis a sequence number. Ordinary attachment bodies are included according to.getAutoDownloadAttachments()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
8bitorbinarycontent, or unencoded text in another charset such as ISO-8859-1 or Shift_JIS, can be misinterpreted or cause an error. Usewhenever byte-exact MIME is required.fetchSingleBd(long, boolean, BinData)- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchSingleAsMimeSb
Downloads one message's MIME into theStringBuilderinsbMime.If
bUidistrue,msgIdis a UID; otherwise,msgIdis a sequence number. Ordinary attachment bodies are included according to.getAutoDownloadAttachments()sbMimeis 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
8bitorbinarycontent, or unencoded text in another charset such as ISO-8859-1 or Shift_JIS, can be misinterpreted or cause an error. Usewhenever byte-exact MIME is required.fetchSingleBd(long, boolean, BinData)- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentsbMime- thesbMimeargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchSingleBd
Downloads one message's MIME bytes into theBinDatainmimeData.If
bUidistrue,msgIdis a UID; otherwise, it is a sequence number. Ordinary attachment bodies are included according to, andgetAutoDownloadAttachments()controls whether the fetch setsgetPeekMode()\Seen.mimeDatais cleared before the operation. On success it contains the downloaded MIME bytes; on failure it remains empty.- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentmimeData- themimeDataargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
fetchSingleHeaderAsMime
Downloads and returns the MIME header block for one message, without downloading the body.If
bUIDistrue,msgIdis a UID; otherwise,msgIdis a sequence number.- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUID- thebUIDargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMailAttachFilename
Returns the filename for attachmentattachIndexrepresented byemail. 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.- Parameters:
email- theemailargument (notnull)attachIndex- theattachIndexargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getMailAttachSize
Returns the size in bytes of attachmentattachIndexrepresented byemail. 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.- Parameters:
email- theemailargument (notnull)attachIndex- theattachIndexargument- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getMailFlag
Returns the state of the flag named byflagNamefrom the IMAP metadata stored in theEmailinemail.1: the flag is set.0: the flag is not set.-1: the requiredckx-imap-*metadata is missing.
Standard flags include
\Seen,\Answered,\Flagged,\Draft, and\Deleted. Custom keywords such as$label1orNonJunkare also supported.Integer-returning methods do not use
LastMethodSuccessto report this condition; test the return value directly.- Parameters:
email- theemailargument (notnull)flagName- theflagNameargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getMailNumAttach
Returns the number of ordinary attachments represented byemail.This method also works with a header-only email or an email fetched while
wasgetAutoDownloadAttachments()false. In those cases it reads theckx-imap-numAttachmetadata, even though theEmailobject's downloaded attachment count can be0.- Parameters:
email- theemailargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getMailSize
Returns the complete server-reported size of theEmailinemail, in bytes, including attachment data.This value may be available even when only the message headers were downloaded.
- Parameters:
email- theemailargument (notnull)- Returns:
- the result (see
ChilkatObject.getLastMethodSuccess()where the description mentions failure)
-
getMailboxStatus
Sends the IMAPSTATUScommand for the mailbox inmailboxand returns the reported values as XML attributes.messages: total number of messages.recent: messages having the\Recentflag.uidnext: expected UID for the next appended message.uidvalidity: mailbox UID-validity value.unseen: messages without the\Seenflag.
<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.
- Parameters:
mailbox- themailboxargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getQuota
Sends the IMAPGETQUOTAcommand for the quota root inquotaRootand returns the server response as JSON.The server must advertise the IMAP
QUOTAcapability.- Parameters:
quotaRoot- thequotaRootargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getQuotaRoot
Sends the IMAPGETQUOTAROOTcommand for the mailbox inmailboxNameand returns the server response as JSON. The server must advertise the IMAPQUOTAcapability.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.
- Parameters:
mailboxName- themailboxNameargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
getServerCert
Stores the certificate presented by the IMAP server for the current or most recent TLS connection in theCertobject supplied ascert.This is useful for certificate inspection, diagnostics, or implementing application-specific trust checks.
- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
hasCapability
Tests whether the capability named bynameappears in the raw capability response incapabilityResponse.capabilityResponseis typically the string returned by. Capability-name matching follows IMAP capability-token semantics.capability()- Parameters:
name- thenameargument (notnull)capabilityResponse- thecapabilityResponseargument (notnull)- Returns:
- the result; this method never throws
ChilkatException
-
idleCheck
Waits up totimeoutMsmilliseconds for unsolicited mailbox updates afterhas entered IMAP IDLE mode.idleStart()timeoutMs=0performs 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>. Anexistsnotification does not automatically change.getNumMessages()Chilkat does not automatically refresh IDLE. The application should periodically call
andidleDone(), typically before 29 minutes have elapsed, to prevent servers with a 30-minute limit from dropping the connection.idleStart()- Parameters:
timeoutMs- thetimeoutMsargument- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
idleDone
public void idleDone()Ends IMAP IDLE mode by sending the protocol'sDONEcontinuation.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
again.idleStart()- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
idleStart
public void idleStart()Sends the IMAPIDLEcommand and begins listening for unsolicited mailbox updates.The session must be connected, authenticated, and have a mailbox selected with
orselectMailbox(String). The server must advertise theexamineMailbox(String)IDLEcapability.Calling this method while IDLE is already active fails. While IDLE is active, any other method that sends an IMAP command also fails; call
first.idleDone()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.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
isConnected
public boolean isConnected()Returns the last known connection state without sending data to the IMAP server.A
trueresult does not prove that an idle connection is still usable. Callto send a command and verify that the server responds.noop()- Returns:
- the result; this method never throws
ChilkatException
-
isLoggedIn
public boolean isLoggedIn()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.
- Returns:
- the result; this method never throws
ChilkatException
-
login
Authenticates the connected IMAP session using the login name inloginNameand the credential inpassword.Call
first. The mechanism is selected byconnect(String).getAuthMethod()For
XOAUTH2,loginNameis the normal IMAP login name or email address andpasswordis the raw OAuth 2.0 access token without aBearerprefix. 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.
- Parameters:
loginName- theloginNameargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
loginSecure
Authenticates the connected IMAP session using theSecureStringlogin name inloginNameand credential inpassword.This is the secure-string counterpart of
. The authentication mechanism is selected bylogin(String, String).getAuthMethod()For
XOAUTH2,loginNamecontains the normal login name or email address andpasswordcontains the raw access token without aBearerprefix.- Parameters:
loginName- theloginNameargument (notnull)password- thepasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
logout
public void logout()Sends the IMAPLOGOUTcommand and ends the authenticated session.The server normally closes the connection as part of a successful logout.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
mbxList
Lists matching mailboxes and appends them to theMailboxesobject inmboxes.mboxesis not cleared on success, so repeated calls on the same object can add duplicate entries. If the method fails,mboxesis unchanged.subscribed=true: list only subscribed mailboxes.subscribed=false: list all matching mailboxes.
referenceis the IMAP reference name, usually an empty string.mbxPatternis 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
from the server's response.getSeparatorChar()- Parameters:
subscribed- thesubscribedargumentreference- thereferenceargument (notnull)mbxPattern- thembxPatternargument (notnull)mboxes- themboxesargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
moveMessages
Moves the messages identified by theMessageSetinmessageSetfrom the selected mailbox to destination mailboxdestFolderusing one IMAPMOVEcommand.The server must advertise the
MOVEcapability. If it does not, this method fails and does not emulate the operation with copy, delete, and expunge commands.MessageSet.HasUidsdetermines whethermessageSetcontains 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.
- Parameters:
messageSet- themessageSetargument (notnull)destFolder- thedestFolderargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
noop
public void noop()Sends the IMAPNOOPcommand 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.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
queryMbx
Searches the selected mailbox using the IMAP criteria incriteriaand stores matching identifiers in theMessageSetinmsgSet.On success,
msgSetis replaced with the result. IfbUidistrue,msgSetcontains UIDs andMessageSet.HasUidsistrue; otherwise,msgSetcontains sequence numbers andMessageSet.HasUidsisfalse. If the method fails,msgSetis unchanged.applies when the criteria contain non-ASCII text.getSearchCharset()For the special criterion
new-email, Chilkat records eachUIDNEXTreceived fromSELECT,EXAMINE, or another IMAP response and uses it as the baseline for detecting later UIDs. If noUIDNEXTis available, Chilkat searches for messages having the\Recentflag. Results are always UIDs regardless ofbUid, and an empty result clearsmsgSet.When
is nonempty, Chilkat uses IMAPgetSortCriteria()SORTif the server supports it. Otherwise, it automatically falls back to an ordinarySEARCH.- Parameters:
criteria- thecriteriaargument (notnull)bUid- thebUidargumentmsgSet- themsgSetargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
queryThread
Sends the IMAPTHREADcommand for the selected mailbox.threadAlgis the threading algorithm, commonlyORDEREDSUBJECTorREFERENCES.searchCriteriacontains ordinary IMAP search criteria and is interpreted using. IfgetSearchCharset()bUidistrue, message identifiers in the result are UIDs; otherwise, they are sequence numbers.On success,
jsonis completely replaced with the thread hierarchy. On failure,jsonis unchanged; there is no partial-success JSON result.The returned JSON has a top-level
threadsarray. Each element represents one thread, and nested arrays encode parent/child relationships. For example:{"threads":[[1],[2],[3]]}The server must advertise the IMAP
THREADcapability and support the selected algorithm.- Parameters:
threadAlg- thethreadAlgargument (notnull)searchCriteria- thesearchCriteriaargument (notnull)bUid- thebUidargumentjson- thejsonargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
rawCommandBd
Sends the raw IMAP command bytes in theBinDatainbdCmdand stores the raw response bytes inbdResp.bdCmdcontains the command without an IMAP command tag or trailing CRLF; Chilkat supplies both.bdRespis 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, orUidValidity. State-changing raw commands can leave cached properties inconsistent with the server.- Parameters:
bdCmd- thebdCmdargument (notnull)bdResp- thebdRespargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
refetchMailFlags
Fetches the current IMAP flags for the server message represented byemailand updates itsckx-imap-*metadata headers.Chilkat reads the identifier from
ckx-imap-uidand checksckx-imap-isUidto determine whether it is a UID or sequence number. A copiedEmailcan be used as long as this metadata is preserved.When
ckx-imap-isUidisNO, the stored sequence number may identify a different message after an expunge. UID-based emails are preferred for later operations. Methods such asread the refreshed flag metadata.getMailFlag(Email, String)- Parameters:
email- theemailargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
renameMailbox
Renames the mailbox infromMailboxto the name intoMailbox.Changing hierarchy components can also move a mailbox within the server's folder tree, for example from
INBOX.old.projecttoINBOX.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.
- Parameters:
fromMailbox- thefromMailboxargument (notnull)toMailbox- thetoMailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
selectMailbox
Opens the mailbox inmailboxfor 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
,getSelectedMailbox(),getNumMessages(), and related mailbox-state properties.getUidValidity()Use
when read-only access is required.examineMailbox(String)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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sendRawCommand
Sends the raw IMAP command text incmdand 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, orUidValidity. State-changing raw commands can leave cached properties inconsistent with the server.- Parameters:
cmd- thecmdargument (notnull)- Returns:
- the result (never
null) - Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert
Specifies theCertincertfor decrypting S/MIME messages downloaded by thisImapobject.The certificate must have access to its associated private key. Use
when the private key is supplied separately.setDecryptCert2(Cert, PrivateKey)- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setDecryptCert2
Specifies the certificate incertand its separately suppliedPrivateKeyinkeyfor decrypting S/MIME messages.Use this when the certificate object does not already provide access to the private key.
- Parameters:
cert- thecertargument (notnull)key- thekeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFlag
Sets or clears one flag on the message identified bymsgIdin the selected mailbox.If
bUidistrue,msgIdis a UID; otherwise, it is a sequence number.flagNameis the flag name, andvalueis1to set the flag or0to clear it.Standard flags include
\Deleted,\Seen,\Answered,\Flagged, and\Draft. Server-supported custom keywords may also be used.- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentflagName- theflagNameargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setFlags
Sets or clears one flag for every identifier in theMessageSetsupplied inmessageSet.flagNameis the flag name, andvalueis1to set it or0to clear it.MessageSet.HasUidsdetermines whether the identifiers are UIDs or sequence numbers. Chilkat sends one IMAPSTOREorUID STOREcommand 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
Emailobjects.- Parameters:
messageSet- themessageSetargument (notnull)flagName- theflagNameargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setMailFlag
Sets or clears a flag for the server message represented by theEmailinemail.Chilkat reads the message identifier from
ckx-imap-uidand usesckx-imap-isUidto determine whether the value is a UID or sequence number.flagNameis the flag name, andvalueis1to set it or0to clear it. The method fails if the required metadata is absent.A copied
Emailcan be used as long as the metadata is preserved. Whenckx-imap-isUidisNO, 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
\Deletedmarks the message for deletion; callto remove it permanently.expunge()- Parameters:
email- theemailargument (notnull)flagName- theflagNameargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setQuota
Sends the IMAPSETQUOTAcommand for quota rootquotaRoot.resourceisSTORAGEto set the combined message-storage limit orMESSAGEto set the message-count limit. ForSTORAGE,quotais measured in units of 1024 octets; for example,500000represents approximately 500,000,000 bytes.The server must support the IMAP
QUOTAextension and the requested resource type.- Parameters:
quotaRoot- thequotaRootargument (notnull)resource- theresourceargument (notnull)quota- thequotaargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSslClientCert
Specifies the client certificate incertfor TLS client-certificate authentication.Most IMAP servers do not require a client certificate. When one is required,
certmust provide access to the corresponding private key.- Parameters:
cert- thecertargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSslClientCertPem
Specifies a TLS client certificate and private key from PEM data or a PEM file.pemDataOrFilenamemay contain the PEM text itself or a local filesystem path to the PEM file; Chilkat detects which form was supplied.pemPasswordcontains the password when the private key is encrypted.- Parameters:
pemDataOrFilename- thepemDataOrFilenameargument (notnull)pemPassword- thepemPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setSslClientCertPfx
Specifies a TLS client certificate and private key from a PKCS #12/PFX file.pfxFilenameis the local filesystem path of the.pfxor.p12file, andpfxPasswordcontains its password.- Parameters:
pfxFilename- thepfxFilenameargument (notnull)pfxPassword- thepfxPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sshAuthenticatePk
Authenticates the SSH tunnel using the username insshLoginand theSshKeyprivate key inprivateKey.Call
first. The corresponding public key must already be authorized forsshOpenTunnel(String, int)sshLoginon the SSH server. After authentication, callandconnect(String)for the IMAP server.login(String, String)- Parameters:
sshLogin- thesshLoginargument (notnull)privateKey- theprivateKeyargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sshAuthenticatePw
Authenticates the SSH tunnel using the username insshLoginand password insshPassword.Call
first. After SSH authentication succeeds, callsshOpenTunnel(String, int)andconnect(String); the IMAP traffic then flows through the tunnel automatically.login(String, String)- Parameters:
sshLogin- thesshLoginargument (notnull)sshPassword- thesshPasswordargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sshCloseTunnel
public void sshCloseTunnel()Closes the SSH tunnel opened by.sshOpenTunnel(String, int)Any IMAP connection using that tunnel must no longer be used after the tunnel is closed.
- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
sshOpenTunnel
Connects to the SSH server insshHostnameon portsshPortand prepares an SSH tunnel for the later IMAP connection.Port
22is the usual SSH port. After this succeeds, authenticate withorsshAuthenticatePw(String, String), then callsshAuthenticatePk(String, SshKey)andconnect(String)for IMAP.login(String, String)- Parameters:
sshHostname- thesshHostnameargument (notnull)sshPort- thesshPortargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
storeFlags
Sets or clears multiple flags on one message in the selected mailbox.If
bUidistrue,msgIdis a UID; otherwise, it is a sequence number.flagNamesis a space-separated list such as\Seen \Answered $label1.valueis1to set all listed flags or0to clear them.The operation uses IMAP
STOREorUID STOREand 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 fetchedEmailobjects.- Parameters:
msgId- themsgIdargument (0 .. 4294967295)bUid- thebUidargumentflagNames- theflagNamesargument (notnull)value- thevalueargument- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
subscribe
Subscribes the authenticated IMAP account to the mailbox named bymailbox.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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
unsubscribe
Removes the subscription to the mailbox named bymailbox.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.
- Parameters:
mailbox- themailboxargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useCertVault
Associates theXmlCertVaultinvaultwith thisImapobject 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.
- Parameters:
vault- thevaultargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useSsh
Uses an already connected and authenticatedSshobject 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(String)- Parameters:
ssh- thesshargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
useSshTunnel
Uses the existing SSH tunnel represented by theSocketintunnelfor subsequent IMAP connections.This allows a tunnel to be shared with other objects. Call this method before
.connect(String)- Parameters:
tunnel- thetunnelargument (notnull)- Throws:
ChilkatException- if the operation fails;ChilkatException.getLastErrorText()says why
-
setProgressListener
Installs the listener that receives this object's progress events (abortCheck,percentDone,progressInfo) during its long-running methods; replaces any listener or lambda installed before;nullremoves it.- Parameters:
listener- the listener, ornull- Throws:
IllegalStateException- if called from inside one of this object's own callbacks
-
getProgressListener
Returns the installed listener, ornull.- Returns:
- the listener installed with
setProgressListener(ProgressListener)or one of theon...methods
-
onAbortCheck
Installs a listener whose only callback isabortCheck: called everyHeartbeatMsmilliseconds during a long-running method; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onPercentDone
Installs a listener whose only callback ispercentDone: called with the completion percentage (0..100) as a long-running method progresses; returntrueto abort it. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-
onProgressInfo
Installs a listener whose only callback isprogressInfo: called with a name/value pair of progress information as a long-running method proceeds. Replaces any listener installed before.- Parameters:
callback- the callback, ornullto remove the listener
-