Function API only Updated 17 Oct 2026
imap.getCount(session, [folder])
Retrieves the current number of messages in the inbox.
Parameters
sessionobjectrequiredIMAP session object obtained from imap.connect().
folderstringoptionalName of the folder to count. Default is the inbox.
Returns
The number of messages in the folder. Throws if the session is not connected and logged in.
Example
Normal JavaScript, running in the browser or on the Docly™ server.
// Configure connection (see imap.connect example)
let config = {
"hostname" : "serverhost",
"port" : 993, // useSsl: true = TLS from the start. Use 143 with useSsl: false
"useSsl" : true,
"username" : "login",
"password" : "pass",
"method" : "Login"
};
let session = imap.connect(config);
let messageCount = imap.getCount(session);
write(messageCount);