I'm trying to iterate over tibble to send emails from each row and can't get it to work. Here is example:
packages
library(tidyverse)
library(sendmailR)
library(pander)
First create table I want to include to email
tbl <- tibble(A = c(1,2,3),
B = c(4,5,6),
C = c(7,8,9))
table <- pander_return(tbl)
Create tibble, each column corresponds to certain information I want to include to email
emails <- tibble(from = c("jane.doe@gm.com", "john.doe@gm.com"),
to = c("jane.doe@gm.com", "john.doe@gm.com"),
subject = "This is test",
greetings = "Happy Christmas",
data = list(table, table))
Now I would like to map
each column and add it to correct place to sendmail
function from sendmailR package. Here is example how I can send 1 email. Only interesting bit is how greetings
and table
are joined together to create msg field.
from <- "jane.doe@gm.com"
to <- "jane.doe@gm.com"
subject <- "This is test"
msg <- c(greetings, table)
sendmailR::sendmail(from = from, to = to, subject = subject, msg = msg)
So how can I map that emails tibble to sendmail
function, so email would be sent by each row.