The goal of outlookMailer is to create an R interface between Microsoft Outlook and R, to compose messages from R using Outlook’s native window.
It works only on Windows.
The package requires access to Windows DCOM objects, provided by RDCOMClient.
It is no longer on CRAN, but can be installed from GitHub:
The package wraps the COM interface to Microsoft Outlook with user-friendly R functions.
One retrieves/sets properties with [[
and ]]
accessors.
One calls methods with the $
accessor.
library(outlookMailer)
# Create a connection to Outlook
con <- connect_outlook()
# Create a message and show it
msg <- create_draft(con,
addr_to = 'foo@bar.com',
body_plain = 'Body of the message',
use_signature = TRUE,
show_message = FALSE)
# Optionally modify properties
msg[['Subject']] <- 'Subject of the message'
# Show the message
msg$Display()
# Send the message (caution!)
# msg$Send()
# Close and save to drafts
close_draft(msg, save = TRUE)
Most functions are pipe-friendly:
connect_outlook() %>%
create_draft(body_plain = 'Test') %>%
close_draft(save = TRUE) %>%
disconnect_outlook()