
Last chance! 50% off unlimited learning
Sale ends in
Configure an IMAP connection using the ImapCon
R6
class.
new()
Configure and create a new IMAP connection.
ImapCon$new(
url,
username,
password = NULL,
xoauth2_bearer = NULL,
use_ssl = TRUE,
verbose = FALSE,
buffersize = 16000,
timeout_ms = 0,
...
)
url
A character string containing the IMAP server address
username
A character string containing the username.
password
A character string containing the user's password.
xoauth2_bearer
A character string containing the oauth2 bearer token.
use_ssl
A logical indicating the use or not of Secure Sockets Layer
encryption when connecting to the IMAP server. Default is TRUE
.
verbose
If FALSE
, mutes the flow of information between the
server and the client. Default is FALSE
.
buffersize
The size in bytes for the receive buffer. Default is
16000 bytes or 16kb, which means it will use the libcurl's default value.
According to the libcurl's documentation, the maximum buffersize is 512kb
(or 512000 bytes), but any number passed to buffersize
is treated
as a request, not an order.
timeout_ms
Time in milliseconds (ms) to wait for the execution or re-execution of a command. Default is 0, which means that no timeout limit is set.
...
Further curl parameters (see curl::curl_options
) that
can be used with the IMAP protocol. Only for advanced users.
A new `ImapCon` object.
reset_url()
Reset the previously informed url
ImapCon$reset_url(x)
x
A character string containing a new url to be set.
reset_username()
Reset the previously informed username
ImapCon$reset_username(x)
x
A character string containing a new username to be set.
reset_use_ssl()
Reset the previously informed use_ssl parameter
ImapCon$reset_use_ssl(x)
x
A logical indicating the use or not of Secure Sockets Layer
encryption when connecting to the IMAP server. Default is TRUE
.
reset_verbose()
Reset the previously informed verbose parameter
ImapCon$reset_verbose(x)
x
If FALSE
, mutes the flow of information between the
server and the client.
reset_buffersize()
Reset the previously informed buffersize parameter
ImapCon$reset_buffersize(x)
x
The size in bytes for the receive buffer. Default is
16000 bytes or 16kb, which means it will use the libcurl's default value.
According to the libcurl's documentation, the maximum buffersize is 512kb
(or 512000 bytes), but any number passed to buffersize
is treated
as a request, not an order.
reset_timeout_ms()
Reset the previously informed buffersize parameter
ImapCon$reset_timeout_ms(x)
x
Time in milliseconds (ms) to wait for the execution or re-execution of a command. Default is 0, which means that no timeout limit is set.
reset_password()
Reset the previously informed password
ImapCon$reset_password(x)
x
A character string containing the user's password.
reset_xoauth2_bearer()
Reset the previously informed oauth2 bearer token
ImapCon$reset_xoauth2_bearer(x)
x
A character string containing the oauth2 bearer token.
list_server_capabilities()
List the server's IMAP capabilities.
ImapCon$list_server_capabilities(retries = 1)
retries
Number of attempts to connect and execute the command.
Default is 1
.
A character vector
containing the server's IMAP capabilities.
\dontrun{
cap <- con$list_server_capabilities()
cap
}
list_mail_folders()
List mail folders in a mailbox.
ImapCon$list_mail_folders(retries = 1)
retries
Number of attempts to connect and execute the command.
Default is 1
.
A list
containing the mail folder names and their inherent
structure.
\dontrun{
folders <- con$list_mail_folders()
folders
}
select_folder()
Select a mail folder.
ImapCon$select_folder(name, mute = FALSE, retries = 1)
name
A string containing the name of an existing mail folder on the user's mailbox.
mute
A logical
. If TRUE
, mutes the confirmation message
when the command is successfully executed. Default is FALSE
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A list
containing the mail folder names and their inherent
structure.
\dontrun{
con$select_mail_folder(name = "INBOX")
}
examine_folder()
Examine the number of messages in a mail folder.
ImapCon$examine_folder(name = NULL, retries = 1)
name
A character
string containing the name of an existing
mail folder on the user's mailbox. If no name is passed, the command
will be executed using the previously selected mail folder name.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A vector
(with names "EXISTS"
and "RECENT"
)
containing the number of messages in each category.
\dontrun{
con$select_folder(name = "INBOX")
con$examine_folder()# or directly:
con$examine_folder("Sent")
}
create_folder()
Create a new mail folder.
ImapCon$create_folder(name, mute = FALSE, retries = 1)
name
A string containing the name of the new mail folder to be created.
mute
A logical
. If TRUE
, mutes the confirmation message
when the command is successfully executed. Default is FALSE
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
TRUE
in case the operation is successful.
\dontrun{
con$create_folder(name = "New Folder Name")
}
rename_folder()
Rename a mail folder.
ImapCon$rename_folder(
name = NULL,
new_name,
reselect = TRUE,
mute = FALSE,
retries = 1
)
name
A string containing the name of the new mail folder to be renamed. If no name is passed, the command will be executed using the previously selected mail folder name.
new_name
A string containing the new name to be assigned.
reselect
A logical. If TRUE
, calls
select_folder(name = to_folder)
under the hood before returning
the output. Default is TRUE
.
mute
A logical
. If TRUE
, mutes the confirmation message
when the command is successfully executed. Default is FALSE
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
TRUE
in case the operation is successful.
\dontrun{
con$select_folder(name = "Folder A")
con$rename_folder(new_name = "Folder B")
# or directly:
con$rename_folder(name = "Folder A", new_name = "Folder B")
}
list_flags()
List flags in a selected mail folder
ImapCon$list_flags(retries = 1)
retries
Number of attempts to connect and execute the command.
Default is 1
.
TRUE
in case the operation is successful.
\dontrun{
con$select_folder(name = "INBOX")
con$list_flags()
}
search()
Execute a custom search
ImapCon$search(
request,
negate = FALSE,
use_uid = FALSE,
esearch = FALSE,
retries = 1
)
request
A string directly specifying what to search or
constructed by a combination of relational-operator-helper-functions OR
and AND
, and criteria helper functions such as
before
, since
, on
,
sent_before
, sent_since
, sent_on
,
flag
, string
, smaller_than
,
larger_than
, younger_than
, or
younger_than
.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERIA". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A list
containing the flags (character vector
),
the permanent flags (character vector
), and an indication if custom
flags are allowed by the server (logical vector
).
\dontrun{
con$select_folder(name = "INBOX")
# ex1
con$search(OR(before(date_char = "17-Apr-2015"),
string(expr = "John", where = "FROM")))# ex2
con$search(AND(smaller_than(size = "512000"),
string(expr = "John", where = "FROM"),
string(expr = "@ksu.edu", where = "CC")))
}
search_larger_than()
Search by size (LARGER)
ImapCon$search_larger_than(
size,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
size
An integer specifying the size in bytes to be used as the search criterion.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
# search for messages with size larger than 512Kb
con$search_larger_than(size = 512000))
}
search_smaller_than()
Search by size (SMALLER)
ImapCon$search_smaller_than(
size,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
size
An integer specifying the size in bytes to be used as the search criterion.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for messages with size smaller than 512Kb
con$search_smaller_than(size = 512000))
}
search_before()
Search by internal date (BEFORE)
ImapCon$search_before(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for messages with date before "02-Jan-2020", presenting the
# .. results as unique identifiers (UID)
con$search_before(date = "02-Jan-2020", use_uid = TRUE)
}
search_since()
Search by internal date (SINCE)
ImapCon$search_since(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
POSIX*
like objects, since IMAP servers use this uncommon date format.
POSIX*
like, since IMAP servers like this not so common date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for messages with date since "02-Jan-2020", presenting the
# .. results as unique identifiers (UID)
con$search_since(date = "02-Jan-2020", use_uid = TRUE)
}
search_on()
Search by internal date (ON)
ImapCon$search_on(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for messages received on date "02-Jan-2020", presenting the
#... results as unique identifiers (UID)
con$search_on(date = "02-Jan-2020", use_uid = TRUE)
}
search_period()
Search by internal date (Period)
ImapCon$search_period(
since_date_char,
before_date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
since_date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
before_date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for all messages in the mail folder, EXCEPT (negate = TRUE) by
#... those received between the dates "02-Jan-2020" and "22-Mar-2020"
con$search_period(since_date_char = "02-Jan-2020",
before_date_char = "22-Mar-2020",
negate = TRUE))
}
search_sent_before()
Search by origination date (RFC 2822 Header - SENT BEFORE)
ImapCon$search_sent_before(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
# search for messages with date before "02-Jan-2020", presenting the
# .. results as unique identifiers (UID)
con$search_sent_before(date = "02-Jan-2020", use_uid = TRUE)
}
search_sent_since()
Search by origination date (RFC 2822 Header - SENT SINCE)
ImapCon$search_sent_since(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
# search for messages with date before "02-Jan-2020", presenting the
# .. results as unique identifiers (UID)
con$search_sent_since(date = "02-Jan-2020", use_uid = TRUE)
}
search_sent_on()
Search by origination date (RFC 2822 Header - SENT ON)
ImapCon$search_sent_on(
date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for messages received on date "02-Jan-2020", presenting the
#... results as unique identifiers (UID)
con$search_sent_on(date = "02-Jan-2020", use_uid = TRUE)
}
search_sent_period()
Search by origination date (RFC 2822 Header - SENT Period)
ImapCon$search_sent_period(
since_date_char,
before_date_char,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
since_date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
before_date_char
A character string
with format "DD-Mon-YYYY", e.g.
"01-Apr-2019". We opt not to use Date
or POSIX*
like
objects, since IMAP servers use this uncommon date format.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for all messages in the mail folder, EXCEPT (negate = TRUE) by
#... those received between the dates "02-Jan-2020" and "22-Mar-2020"
con$search_sent_period(since_date_char = "02-Jan-2020",
before_date_char = "22-Mar-2020",
negate = TRUE))
}
search_flag()
Search by flag(s)
ImapCon$search_flag(
name,
negate = FALSE,
use_uid = FALSE,
esearch = FALSE,
retries = 1
)
name
A string containing one or more flags to search for. Use
ImapCon$list_flags()
to list the flags
in a selected mail folder.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for all messages in the mail folder that are marked as "SEEN" AND
#.. "ANSWERED"
con$search_flag(name = c("SEEN", "ANSWERED"))
}
search_older_than()
Search WITHIN a specific time (OLDER)
ImapCon$search_older_than(
seconds,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
seconds
An integer specifying the number of seconds to be used as the search criterion.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for all messages received in the last hour (not older than 3600 seconds)
con$search_older_than(seconds = 3600, negate = TRUE)
}
search_younger_than()
Search WITHIN a specific time (YOUNGER)
ImapCon$search_younger_than(
seconds,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
seconds
An integer specifying the number of seconds to be used as the search criterion.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the results: instead of writing down the whole sequences of messages'
ids, such as {1 2 3 4 5}
, it will be presented as {1:5}
,
which decreases transmission costs. This argument can be used along with
buffersize
to avoid results stripping. Check if your IMAP server
supports ESEARCH
with
ImapCon$list_server_capabilities()
.
retries
Number of attempts to connect and execute the command.
Default is 1
.
A numeric vector
containing the message ids.
\dontrun{
con$select_folder(name = "INBOX")
# search for all messages received in the last hour (younger than 3600 seconds)
con$search_younger_than(seconds = 3600)
}
search_string()
Search by string or expression
ImapCon$search_string(
expr,
where,
negate = FALSE,
use_uid = FALSE,
flag = NULL,
esearch = FALSE,
retries = 1
)
expr
A character string specifying the word or expression to search for in messages.
where
A mandatory character string specifying in which message's Section or Header Field to search for the provided string.
negate
If TRUE
, negates the search and seeks for "NOT SEARCH
CRITERION". Default is FALSE
.
use_uid
Default is FALSE
. In this case, results will be
presented as message sequence numbers. A message sequence number is a
message's relative position to the oldest message in a mail folder. It may
change after deleting or moving messages. If a message is deleted,
sequence numbers are reordered to fill the gap. If TRUE
, the
command will be performed using the "UID"
or unique identifier,
and results are presented as such. UIDs are always the same during the
life cycle of a message in a mail folder.
flag
An optional argument that sets one or more flags as an additional
filter to the search. Use ImapCon$list_flags()
to list the flags in a selected mail folder. Default is NULL
.
esearch
A logical. Default is FALSE
. If the IMAP server has
ESEARCH
capability, it can be used to optimize search results. It
will condense the result
ImapCon$search_string()
:
Heinlein, P. and Hartleben, P. (2008). The Book of IMAP: Building a
Mail Server with Courier and Cyrus. No Starch Press. ISBN 978-1-59327-177-0.
ImapCon$get_attachments()
:
Troost, R., Dorner, S., and K. Moore (1997), Communicating
Presentation Information in Internet Messages: The Content-Disposition
Header Field, RFC 2183, August 1997, https://www.rfc-editor.org/rfc/rfc2183.
ImapCon$fetch_attachments()
:
Troost, R., Dorner, S., and K. Moore (1997), Communicating
Presentation Information in Internet Messages: The Content-Disposition
Header Field, RFC 2183, DOI 10.17487/RFC2183, August 1997,
https://www.rfc-editor.org/rfc/rfc2183.
Other custom search:
AND()
,
OR()
,
before()
,
flag()
,
larger_than()
,
older_than()
,
on()
,
sent_before()
,
sent_on()
,
sent_since()
,
since()
,
smaller_than()
,
string()
,
younger_than()
Other attachments:
list_attachments()