Learn R Programming

mRpostman (version 0.3.1)

get_max_id: Get Maximum Message ID in a Mailbox

Description

Get the greater (maximum) message id in a Mailbox, considering messages with a specific flag.

Usage

get_max_id(imapconf, by = "MSN", flag, retries = 2)

Arguments

imapconf

An object of class imapconf generated with configure_imap and with a mbox item added after a mailbox selection with select_mailbox.

by

Which id (MSN or UID) to use when searching for messages. "MSN" or message squence number is a message's relative position to the older message in the mailbox. It may change after deleting or moving messages. For instance, if a message is deleted, message sequence numbers are reordered to fill the gap. "UID" or unique identifier is always the same during the life cycle of a message. Default is "MSN".

flag

A string specifying the flag to be used for filtering messages. Use flag_options to list the common flags used by IMAP servers. Default is NULL.

retries

Number of attempts to connect and execute the command. Default is 2.

Value

A numeric vector of length 1 indicating the minimum id.

See Also

Other miscellaneous: add_flags, copy_msg, count_msgs, delete_msg, expunge, get_min_id, move_msg, remove_flags, replace_flags

Examples

Run this code
# NOT RUN {
# }
# NOT RUN {
# configure IMAP
library(mRpostman)
imapconf <- configure_imap(url="imaps://your.imap.server.com",
                           username="your_username",
                           password=rstudioapi::askForPassword()
                          )

results <- imapconf %>%
    select_mailbox(mbox = "[Gmail]/Trash") %>%
    get_max_id(by = "UID", flag = "SEEN")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab