
Modify a Gmail thread's label state (archive, trash, star, label, etc.)
Source:R/mc_thread_modify.R
mc_thread_modify.RdAdds and/or removes labels on a thread in one call. Accepts user-defined
label names or Gmail system labels (INBOX, STARRED, UNREAD, IMPORTANT,
TRASH, SPAM, SENT, DRAFT). Covers common operations beyond "labeling":
archive (remove = "INBOX"), star (add = "STARRED"), trash
(add = "TRASH"), mark-read (remove = "UNREAD").
Arguments
- thread_id
Gmail thread ID (e.g. from
mc_thread_find()).- add
Character vector of label names to add.
NULLfor none.- remove
Character vector of label names to remove.
NULLfor none.
Details
Pass names, not IDs. User-label names resolve to opaque IDs via
gmailr::gm_labels(). System labels pass through unchanged. When a user
label's name collides with a system label ID (e.g. a user label named
"STARRED"), the system interpretation wins — almost always what's
intended.
At least one of add or remove must be non-NULL. The gm_labels()
call is skipped entirely when every input is a system label.
Examples
if (FALSE) { # \dontrun{
# Apply a user label
mc_thread_modify("18171fb2cec08e9d", add = "Clients/Acme")
# Archive and mark read in one call
mc_thread_modify("18171fb2cec08e9d", remove = c("INBOX", "UNREAD"))
# Star a thread
mc_thread_modify("18171fb2cec08e9d", add = "STARRED")
# Status transition
mc_thread_modify("18171fb2cec08e9d", add = "Done", remove = "Pending")
} # }