How to extract email ids from a data frame column and send mail automatically using R

162 Views Asked by At

I am using the RDCOMClient library to automate outlook mails from R. Now the count of recipients' mail id changes periodically. Is there any way to automatically access the ** Email ID ** column in a data frame, say df, and send mail automatically?

Below is the existing code with static 2 recipients.

library(RDCOMClient)
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]]=paste("[email protected]","[email protected]", collapse=NULL)

1

There are 1 best solutions below

1
Marshall K On

Sure it sounds easy enough. Consider the following Dataframe

df <- data.frame(emails = c("[email protected]","[email protected]", '[email protected]'))
recipients <- df$emails
OutApp <- COMCreate("Outlook.Application")
outMail = OutApp$CreateItem(0)
outMail[["To"]]=paste(recipients)
recipients