user3773444
user3773444

Reputation: 333

R send email with attachment using sendmailR

I'm trying to attach a file in R using sendmailR.

Is this possible?

excluding attach.files line sends email without issue.

to <- "<me@localhost>"
subject <- "test attachment"
body <- list("test")
attach.files = c("test.jpeg"),
sendmail(from, to, subject, body,
control=list(smtpServer="192.168.0.51"))} 
Error: unexpected '}' in:
"sendmail(from, to, subject, body,
control=list(smtpServer="192.168.0.51"))}"

Upvotes: 0

Views: 895

Answers (1)

user14873402
user14873402

Reputation: 1

Try the following code:

to <- "<me@localhost>"
subject <- "test attachment"
attachment -> mime_part (x = "test.jpeg")
body <- list("test", attachment)
sendmail(from, to, subject, body,
control=list(smtpServer="192.168.0.51"))} 

Upvotes: 0

Related Questions