0

I have a couple of mail-ids in a column and need to send mail automatically through the RDComclient function. The below code is successfully executed but it sends multiple emails to the same sender n times (instead of single mail to every mail-ids). Here n is the total number of rows in the mail-id column. Not sure where I'm missing.

In the below example, all 3 receive 3 e-mails each instead of one

Sample Dataset df:

Mail_id:
jack@reah.com
johnes@reah.com
thej@outlook.com

Code

  for (mail in df$Mail_id) 
  {
    
    outMail = outApp$CreateItem(0)
    
    outMail[["cc"]] = mail
    
    outMail$Send() 
    
   
  }

MSM
  • 69
  • 7

1 Answers1

1

Try putting all mail_ids in one string:

mail_ids<- paste(df$mail_id, collapse=";") 
outMail = outApp$CreateItem(0)
outMail[["cc"]] = mail_ids
outMail$Send() 

You can do unique(df$mail_id) if you suspect duplicate rows of email-ids in df

Muhammad Rasel
  • 704
  • 4
  • 9