Skip to content

Commit

Permalink
Create secret-santa.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Eleng555 committed Dec 6, 2015
1 parent ee4f45f commit a75b34d
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions secret-santa.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import random
import sendgrid
sg = sendgrid.SendGridClient(API_KEY_HERE)

### List of people participating ###
names = ['person1', 'person2', 'person3', 'person4', 'person5', 'person6',
'person7', 'person8', 'person9', 'person10', 'person11', 'person12']


### Add names and emails of people participating ###
### Names must exactly match the ones in "names" array above ###
info = [('person1','[email protected]'), ('person2','[email protected]'),
('person3','[email protected]'), ('person4','[email protected]'),
('person5','[email protected]'), ('person6','[email protected]'),
('person7','[email protected]'), ('person8','[email protected]'),
('person9','[email protected]'), ('person10','[email protected]'),
('person11','[email protected]'), ('person12','[email protected]')]


### Assigns who gets who and makes sure you don't get yourself ###
a = False
ctr = 1
while ctr > 0:
random.shuffle(names)
for x in range (0, len(names)):
if names[x] == info[x][0]:
a = True
if a == True: #if a person gets themself, reshuffle
ctr = 1
a = False
else:
ctr = -1 #exits while loop


### Emails people one by one ###
for x in range(len(names)):
message = sendgrid.Mail()
message.add_to(info[x][1]) #add recipient
message.set_subject("Secret Santa 2015")
message.set_html("""<link href='https://fonts.googleapis.com/css?family=Karla:400,700' rel='stylesheet' type='text/css'>
<div style="font-family:Karla,sans-serif;"> <h1>hi there</h1>
<p>for this year&#39;s secret santa, your person is: """ + names[x] + """</p></div>""") #set email message
message.set_from("SENDER NAME <[email protected]>") #sender info
status = sg.send(message)

0 comments on commit a75b34d

Please sign in to comment.