I have the below dataframe (in reality it spans a couple hundred rows of the same data).
project_number hours team_member project_lead team_member_email
RR711-132 4 Isaac Bell Dan Case ib@blank.com
RR711-135 10 Isaac Bell Lawrence Cowan ib@blank.com
USU887-101 50 Keith Olsen Aaron Anderson aa@blank.com
VE902-102 30 Chase Harmon Isaac Bell ch@blank.com
SS99-133 50 Chase Harmon Jack Spain ch@blank.com
The goal is to send an email to the team member, that includes a table with the details of the project_number, hours, and the project lead.
I am using RDCOMClient to send out the email, and the "purrr" package to loop over the vectors.
mail_fun <- function(name, mail) {
outMail = OutApp$CreateItem(0)
## configure email parameter
outMail[["To"]] = mail
outMail[["subject"]] = "Project hours for next week"
outMail[["HTMLBody"]] = paste0("Dear ", name, "<p>Testing sending hours through R</>")
## send it
outMail$Send()
}
map2(test.df$team_member, test.df$email, ~mail_fun(name = .x, mail = .y))
I know the code needs modification, but the looping works as well as the sending of the email. What I cannot figure out, is how to create a table (dataframe) that is specifically for the team_member and have it sent through email.
For example, an email would be sent to Isaac Bell, and in the body of that email would be a table that looked like this (I don't know how to make a good-looking table here):
Isaac,
You have been assigned the following hours to the following project for this week:
Project Number Hours Project Lead
RR711-132 4 Dan Case
RR711-135 10 Lawrence Cowan