imap.getMessage(session, index / uid, [headersOnly], [folder]) Last updated: 30. May 2026
API only function
Retrieves message by index from inbox using the provided imap session.
See also: Send mail from API function Sending forms by e-mail
Parameters
| Name | Type | Description |
|---|---|---|
| session | object | Session object from imap.connect() |
| index / uid | number | string | Index or UID of email to retrieve. |
| headersOnly (optional) | bool | Default false, if true only header info is returned. |
| folder (optional) | string | Name of folder / tag to get message from. |
Returns
An object with the retrieved email.
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 msg = imap.getMessage(session, 0);