imap.getCount(session, [folder]) Last updated: 30. 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.// Configure connection (see imap.connect example)
let config = {
"hostname" : "serverhost",
"port" : 143,
"useSsl" : true,
"username" : "login",
"password" : "pass",
"method" : "Login"
};
let session = imap.connect(config);
let messageCount = imap.getCount(session);
write(messageCount);