imap.delete(session, message) Last updated: 30. May 2026

API only function

Deletes a specific message from the inbox.

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

Parameters

Name Type Description
session object

Imap session from imap.connect()

message object

Message object of message to delete.
Use the "imap.getMessage" method to retrieve this.

Returns

Null

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 i = imap.connect(config);
let count = imap.getCount(i);
if (count > 0) {
    var msg = imap.getMessage(i, 0);
    imap.delete(i, msg);
    return { "deleted" : msg };
}
return "No messages in inbox";