SHARE
TWEET

Untitled

a guest Mar 21st, 2017 67 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #######################################################################################
  2. #### Script to send emails out to hosts and guests for Guess Who's Coming to Dinner,
  3. #### City Reformed Presbyterian Church's annual event pairing people with random/secret
  4. #### dinner partners. This script takes information about participants and emails them.
  5. #### Author: Kevin Soo
  6. #######################################################################################
  7.  
  8. # load libraries
  9. library(tidyverse)
  10. library(gmailr)
  11.  
  12. # read guest/host details
  13. df <- read.csv("GWCTD_groups_2017_mail.csv")
  14.  
  15. #### send emails
  16. for (i in 1:nrow(df)) {
  17.     # for hosts
  18.     if (df$type[i]=="Host") {
  19.         email <- mime(
  20.             To = as.character(df$email[i]),
  21.             From = "wac@cityreformed.org",
  22.             Subject = "Host for GWCTD 2017",
  23.             body = paste("Dear ", df$name[i], ",\n\n",
  24.                          "Thank you for participating in Guess Who’s Coming to Dinner 2017! You have been assigned as a host for dinner on 3/25 at 6:00pm. On your signup, you indicated you could make ", df$main[i], ". Your guests will bring the sides and dessert. If any dietary restrictions are listed, please keep them in mind when making your dish. Other details of your dinner party are...\n",
  25.                          "Adults coming: ", df$adultsComing[i], "\n",
  26.                          "Children coming: ", df$childrenComing[i], "\n",
  27.                          "Allergies / Dietary restrictions of anyone in group: ", df$allergies[i], "\n\n",
  28.                          "Your guests’ sides / dessert will also take any listed dietary restrictions into account. During your meal, please consider taking a group photo and submitting it to wac@cityreformed.org.\n\n",
  29.                          "(Please note that we have been doing GWCTD for many years now, so at this point it is getting quite difficult to create dinner parties of people who don’t know each other. We see this as an encouraging challenge, because it indicates how interconnected people in our church are becoming. If you discover that you are already connected with some people in your dinner party in a particular way, we hope you will take this opportunity to learn something new about them. Everyone has a story to tell!)\n\n",
  30.                          "Bon appétit!\nEvelyn (on behalf of WAC)", sep="")
  31.         )
  32.     }
  33.     # for guests
  34.     else if (df$type[i]=="Guest") {
  35.         email <- mime(
  36.             To = as.character(df$email[i]),
  37.             From = "wac@cityreformed.org",
  38.             Subject = "Guest for GWCTD 2017",
  39.             body = paste("Dear ", df$name[i], ",\n\n",
  40.                          "Thank you for participating in Guess Who’s Coming to Dinner 2017! You have been assigned as a guest for dinner on 3/25 at 6:00pm. The details of your dinner party are listed below. If any dietary restrictions are listed, please keep them in mind when making your dish.\n\n",
  41.                          "You have rsvp'd for ", df$adultRsvp[i], " adult(s) and ", df$childRsvp[i], " child(ren)\n",
  42.                          "Your host has signed up to make: ", df$main[i], "\n",
  43.                          "Please bring a: ", df$dish[i], "\n",
  44.                          "Adults (including host): ", df$adults[i], "\n",
  45.                          "Children: ", df$children[i], "\n",
  46.                          "Allergies / Dietary restrictions of anyone in group: ", df$allergies[i], "\n\n",
  47.                          "Here is the address and phone number of your host so you can find your way there:\n",
  48.                          df$address[i], "\n",
  49.                          df$phone[i], "\n\n",
  50.                          "Your host’s meal and other guests’ sides / desserts will also take any dietary restrictions into account. During your meal, please consider taking a group photo and submitting it to wac@cityreformed.org.\n\n",
  51.                          "(Please note that we have been doing GWCTD for many years now, so at this point it is getting quite difficult to create dinner parties of people who don’t know each other. We see this as an encouraging challenge, because it indicates how interconnected people in our church are becoming. If you discover that you are already connected with some people in your dinner party in a particular way, we hope you will take this opportunity to learn something new about them. Everyone has a story to tell!)\n\n",
  52.                          "Bon appétit!\nEvelyn (on behalf of WAC)", sep="")
  53.         )
  54.     }
  55.     send_message(email)
  56.     print(paste("Sent to ", df$email[i], sep=""))
  57. }
RAW Paste Data
Top