Skip to content

IMAP Mark Read

Type: imap-mark-read  ·  Package: SMTP / IMAP Email Activities v1.0.5

Marks an email as read on the IMAP server. Essential in processes that read unread emails: after processing each one you mark it as read so it is not picked up again in the next run. The change is stored on the server, so every client of that account sees it.

Given the mailId (the .Id from IMAP Read), it adds the read flag to that email in folder. It is idempotent: marking an already-read email has no effect. If the UID does not exist in the folder, the server marks nothing and the activity ends without error.

ParameterTypeDefaultDescription
hoststring—IMAP server.
usernamestring—Username.
passwordcredential—Password or App Password. Use credential("name")["password"].
mailIdstring—Email UID (from email.Id). Must be numeric.
ParameterTypeDefaultDescription
portint993IMAP port.
folderstring"INBOX"Folder that holds the email (the same it was read from).
securitystring"ssl"Encryption: auto, none, ssl or starttls.

This activity does not return a value.

MessageCause and fix
Invalid 'mailId'. It must be the numeric UID returned by imap-read.mailId is not a number. Pass email.Id from IMAP Read.
'mailId' is required.The parameter is missing or the expression returned null.
Authentication, folder or connection errorSame as in IMAP Read.
IMAP Read host = "imap.gmail.com" username = credential("mail-bot")["user"] password = credential("mail-bot")["password"]
unreadOnly = true → output: emails
For Each items = emails itemVariable = email
└─ activities:
Try / Catch errorVariable = error
├─ try:
│ ... process ...
│ IMAP Mark Read host = "imap.gmail.com" username = credential("mail-bot")["user"] password = credential("mail-bot")["password"] mailId = email.Id
└─ catch:
Log level = warning message = "Still pending: " + email.Subject + " — " + error.Message