Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Send a email with Attachment in R using Gmail

Tags:

email

r

gmail-api

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.

like image 265
Kshitij Marwah Avatar asked Mar 17 '16 17:03

Kshitij Marwah


People also ask

Can we send mail as attachment in Gmail?

From your inbox, select the email you want to attach. Drag the email into your message. At the bottom, click Send.


1 Answers

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

like image 86
doubleh2 Avatar answered Oct 17 '22 23:10

doubleh2