knitr::opts_chunk$set( collapse = TRUE, comment = "#>", fig.path = "man/figures/README-", out.width = "100%" )
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:
remotes::install_github('omegahat/RDCOMClient')
The package is not on CRAN, install the developer version from here:
remotes::install_github('lgaborini/outlookMailer')
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() ```` ### Attachments Multiple attachments can be supplied as a vector of paths. ```r msg <- create_draft(con, attachments = c('foo.txt', 'foo2.txt'))
Messages saved as .msg
or .eml
can be opened and modified:
con <- connect_outlook() msg <- open_msg(con, path_msg = 'sample.msg', show_message = TRUE)
The package provides a function check if a COM object has a property:
has_COM_property(con, 'Name') con[['Name']] # 'Outlook'
set_from
, set_body
, ...)has_COM_method
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.