Function API only Updated 17 Oct 2026
imap.getMessage(session, index / uid, [headersOnly], [folder])
Retrieves message by index from inbox using the provided imap session.
Parameters
sessionobjectrequiredSession object from imap.connect()
index / uidnumber | stringrequiredIndex of the email to retrieve (a whole number, 0 = first). A string is read as a Message-ID, not a UID.
headersOnlybooloptionalDefault false, if true only header info is returned.
folderstringoptionalName of folder / tag to get message from.
Returns
An object with the retrieved email.
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, // true = TLS from the start (port 993). false = STARTTLS when available (port 143)
"username" : "login",
"password" : "pass",
"method" : "Login"
};
let session = imap.connect(config);
let msg = imap.getMessage(session, 0);