R/search.R

Defines functions build_search SEARCH SEARCH_FROM

Documented in SEARCH

build_search <- function(){
  print("Not implemented yet!")
}

#' SEARCH
#'
#' Search mailbox for messages matching criteria.
#'
#' @param imap imap object
#' @param criteria search criteria like 'ALL', 'UNSEEN', 'FROM "stefan"'
#'    et cetera
#'
#' @return updated imap object
#' @export
#'
#' @examples \dontrun{
#'    # with 'imap' as an imap object ...
#'    response <- imap %>%
#'       SEARCH("UNSEEN") %>% execute()
#' }
SEARCH <- function(imap, criteria = "ALL"){
  imap$options %<>% c(customrequest = paste("SEARCH", criteria))
  imap
}

SEARCH_FROM <- function(imap, from){
  criteria <- sprintf('FROM "%s"', from)
  SEARCH(imap, criteria)
}
crazycapivara/imapr documentation built on May 14, 2019, 11:32 a.m.