How to send email from R and Gmail

See how to automate sending email with the R language, a Gmail account, and the gmailr R package

At some point in your R life, you will likely want to share results of your analysis with non-R-using colleagues. There are lots of ways to do this. One of the easiest (and least expensive) is emailing your results.

But it’s kind of sad to automate your entire analysis workflow, only to manually craft and send an email at the end. Fortunately, you don’t have to. There are several R packages that let you send email directly from an R script. In this article, I’ll demo one of them: gmailr by Jim Hester, who’s now a software engineer at RStudio.

Obviously, you’ll need a Gmail account, which is free to set up if you don’t have one. Then, before you can use that account from R, you’ll need to set it up for API access. Here’s how.

Go to (yes, that’s a sub-subdomain). If you don’t already have a developer project, you’ll be asked to create one. 

At the top of your dashboard, you should see a choice to “Enable APIs and Services.” Click that.

To continue reading this article register now