Learn R Programming

mRpostman (version 0.3.1)

count_msgs: Count the Number of Messages

Description

Counts the number of messages with a respective flag in a mailbox.

Usage

count_msgs(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.

retries

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

Value

A numeric vector of length 1 containing the number of messages that meet the specified criteria.

See Also

Other miscellaneous: add_flags, copy_msg, delete_msg, expunge, get_max_id, 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 = "INBOX") %>%
    count_msgs(by = "UID", flag = "SEEN")

# }
# NOT RUN {
# }

Run the code above in your browser using DataLab