Last chance! 50% off unlimited learning
Sale ends in
Functions that allows searching for messages using the (internal) date criteria, such as before, since, on, and period.
search_on(imapconf, date_char, negate = FALSE, by = "MSN",
flag = NULL, esearch = FALSE, return_imapconf = TRUE,
retries = 2)
An object of class imapconf
generated with
configure_imap and with a mbox
item added after a
mailbox selection with select_mailbox.
A character vector with format "DD-Mon-YYYY", e.g. "01-Apr-2019". We opted not to use objects of type "date", since IMAP servers like this not so common date format.
If TRUE
, negates the search and seeks for
"NOT search_criterion". Default is FALSE
.
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"
.
Optional parameter that adds a flag filter to the search. Use
flag_options to list the common flags used by IMAP servers.
Default is NULL
.
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
allows to condense results to message sets to cut down on transmission
costs, e.g. 1:5
instead of writing ids individually such as
1,2,3,4,5
. It can be used along with buffersize to avoid results
stripping. Check if your IMAP server supports SEARCH
with
list_server_capabilities
.
A logical. If TRUE
, the function returns a
list
of length 2
, containing the imapconf
object
(IMAP settings) and the search results as message ids ("MSN"
or
"UID"
). If FALSE
, returns only the message ids as a numeric
vector. Default is TRUE
.
Number of attempts to connect and execute the command. Default
is 2
.
Depending on the return_imapconf
parameter, it can be a
list
of length 2
containing the imapconf
object
and message ids resulted from search, or a numeric vector containing
only message ids.
Resnick, P., Ed., "Internet Message Format", RFC 5322, 10.17487/RFC5322, October 2008, https://www.rfc-editor.org/info/rfc5322.
Babcock, N., "Introduction to IMAP", Blog, May 2016, https://nbsoftsolutions.com/blog/introduction-to-imap.
Other Date-search operations: custom_search
,
search_before
, search_period
,
search_sent_before
,
search_sent_on
,
search_sent_period
,
search_sent_since
,
search_since
# NOT RUN {
# }
# NOT RUN {
# configure IMAP
library(mRpostman)
imapconf <- configure_imap(url="imaps://your.imap.server.com",
username="your_username",
password=rstudioapi::askForPassword()
)
# list mailboxes
results <- imapconf %>%
list_mailboxes()
# search 1
result1 <- imapconf %>%
select_mailbox(mbox = "INBOX") %>%
search_on(date_char = "17-Dec-2003")
# search 2 (mailboxes with compound names)
result2 <- imapconf %>%
select_mailbox(mbox = "Special Mailbox") %>%
search_on(date_char = "17-Sep-2018", flag = "UNDELETED")
# depending on results, it might be necessary to increase buffersize in
# configure_imap()
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab