Kshitij Marwah
Kshitij Marwah

Reputation: 1151

Send a email with Attachment in R using Gmail

I am trying to attach a file from my system to send it to an email id using R. I am using the gmailr package to send the mails. I have tried the following code for the same.

library(gmailr)

mime() %>%
to("[email protected]") %>%
from("[email protected]") %>%
text_body("My First Email using R.") -> first_part

first_part %>%
subject("Test Mail from R") %>%
attach_file("BazaarQueriesforURLData.txt") -> file_attachment

send_message(file_attachment)

I have been able to send text based messages but I am unable to send attachments from R. My attachment in the default directory folder only.I have seen many solutions on internet but I am unable to find a solution.

I would like to have a solution that has proper OAuth or Json based authentication as Google blocked my attempt to use smtp based authentication.

Upvotes: 13

Views: 3212

Answers (2)

doubleh2
doubleh2

Reputation: 105

Here's a tool in development:

# install.packages("devtools")

library(devtools)
install_github("gmailR", "trinker")

*if you use Windows, you'll need to use Rtools and devtools to install

Upvotes: 1

Related Questions