Last active
March 21, 2017 13:21
-
-
Save kevinsoo/32e46adde8df38b3c70a9fa50d06ad0d to your computer and use it in GitHub Desktop.
Automate emails from a spreadsheet for GWCTD
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ####################################################################################### | |
| #### Script to send emails out to hosts and guests for Guess Who's Coming to Dinner, | |
| #### City Reformed Presbyterian Church's annual event pairing people with random/secret | |
| #### dinner partners. This script takes information about participants and emails them. | |
| #### Author: Kevin Soo | |
| ####################################################################################### | |
| # load libraries | |
| library(tidyverse) | |
| library(gmailr) | |
| # read guest/host details | |
| df <- read.csv("GWCTD_groups_2017_mail.csv") | |
| #### send emails | |
| for (i in 1:nrow(df)) { | |
| # for hosts | |
| if (df$type[i]=="Host") { | |
| email <- mime( | |
| To = as.character(df$email[i]), | |
| From = "wac@cityreformed.org", | |
| Subject = "Host for GWCTD 2017", | |
| body = paste("Dear ", df$name[i], ",\n\n", | |
| "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", | |
| "Adults coming: ", df$adultsComing[i], "\n", | |
| "Children coming: ", df$childrenComing[i], "\n", | |
| "Allergies / Dietary restrictions of anyone in group: ", df$allergies[i], "\n\n", | |
| "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", | |
| "(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", | |
| "Bon appétit!\nEvelyn (on behalf of WAC)", sep="") | |
| ) | |
| } | |
| # for guests | |
| else if (df$type[i]=="Guest") { | |
| email <- mime( | |
| To = as.character(df$email[i]), | |
| From = "wac@cityreformed.org", | |
| Subject = "Guest for GWCTD 2017", | |
| body = paste("Dear ", df$name[i], ",\n\n", | |
| "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", | |
| "You have rsvp'd for ", df$adultRsvp[i], " adult(s) and ", df$childRsvp[i], " child(ren)\n", | |
| "Your host has signed up to make: ", df$main[i], "\n", | |
| "Please bring a: ", df$dish[i], "\n", | |
| "Adults (including host): ", df$adults[i], "\n", | |
| "Children: ", df$children[i], "\n", | |
| "Allergies / Dietary restrictions of anyone in group: ", df$allergies[i], "\n\n", | |
| "Here is the address and phone number of your host so you can find your way there:\n", | |
| df$address[i], "\n", | |
| df$phone[i], "\n\n", | |
| "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", | |
| "(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", | |
| "Bon appétit!\nEvelyn (on behalf of WAC)", sep="") | |
| ) | |
| } | |
| send_message(email) | |
| print(paste("Sent to ", df$email[i], sep="")) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment