imap.getCount(session, [folder]) Last updated: 01. May 2026

API only function

Retrieves the current number of messages in the inbox.

See also: Send mail from API function Sending forms by e-mail

Parameters

Name Type Description
session object IMAP session object obtained from imap.connect().
folder (optional) string Name of folder to get message count from.

Returns

Total number of emails in the inbox.

Example

Code example (JS)

JS is normal JavaScript either running in the browser or on the Docly™ server.
let session = imap.connect(config);
let messageCount = imap.getCount(session);
write(messageCount);