Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Download Gmail Mail Content using R

Tags:

email

r

message

I am trying to download gmails from my gmail account. Most importantly I am interested in downloading the actual content of the mail along with other parameters receipt time, subject, to and from address. I have tried using gmailr and edeR packages. While gmailr helps in sending mails (which I have tried successfully, edeR helps in downloading only the topline data and not the message body. I am seeking this data to test an classification model. Is there a way to do it in R...I am not familiar with any other language.

like image 347
Apricot Avatar asked Nov 03 '15 16:11

Apricot


People also ask

How do I download the contents of an email?

Save a message as a file on your computer or in the cloudDouble-click to open the message you want to save, and on the File menu, click Save As. In the Save as dialog box, in the Folder pane, choose a folder, and then the location in that selected folder where you want to save the file.


1 Answers

You could manually retrieve an archive of your gmail and use convert_mbox_eml() from the tm.plugin.mail package to convert your .mbox (several mails in a single box) into an eml format (every mail in a single file) and then load it in a VCorpus using readMail:

library(tm)
library(tm.plugin.mail)

mail <- paste0(getwd(), "/mail")
convert_mbox_eml("yourarchive.mbox", mail)
vc <- VCorpus(DirSource(mail), readerControl = list(reader = readMail))
like image 82
Steven Beaupré Avatar answered Sep 29 '22 09:09

Steven Beaupré