imap.getCount(session, [folder]) Last updated: 26. Nov 2024

API only function

Retrieves the current number of messages in the inbox.

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);