Skip to content

Commit add5ec9

Browse files
Too many dependency issues
1 parent b384471 commit add5ec9

File tree

4 files changed

+69
-1
lines changed

4 files changed

+69
-1
lines changed
8.69 KB
Binary file not shown.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#! /usr/bin/python3.5
2+
3+
4+
"""
5+
6+
Author: Samrat Banerjee
7+
Dated: 10/09/2018
8+
Description: Project: Sends emails based on payment status in spreadsheet.
9+
10+
"""
11+
12+
import openpyxl, smtplib, sys
13+
14+
# Open the spreadsheet and get the latest dues status.
15+
wb = openpyxl.load_workbook('duesRecords.xlsx')
16+
sheet = wb.get_sheet_by_name('Sheet1')
17+
18+
lastCol = sheet.get_highest_column()
19+
latestMonth = sheet.cell(row=1, column=lastCol).value
20+
21+
# Check each member's payment status.
22+
unpaidMembers = {}
23+
for r in range(2, sheet.get_highest_row() + 1):
24+
payment = sheet.cell(row=r, column=lastCol).value
25+
if payment != 'paid':
26+
name = sheet.cell(row=r, column=1).value
27+
email = sheet.cell(row=r, column=2).value
28+
unpaidMembers[name] = email
29+
30+
# Log in to email account.
31+
smtpObj = smtplib.SMTP('smtp.gmail.com', 587)
32+
smtpObj.ehlo()
33+
smtpObj.starttls()
34+
smtpObj.login('my_email_address@gmail.com', sys.argv[1])
35+
36+
# Send out reminder emails.
37+
for name, email in unpaidMembers.items():
38+
body = "Subject: %s dues unpaid.\nDear %s,\nRecords show that you have not paid dues for %s. Please make this payment as soon as possible. Thank you!'" %(latestMonth, name, latestMonth)
39+
print('Sending email to %s...' % email)
40+
sendmailStatus = smtpObj.sendmail('my_email_address@gmail.com', email, body)
41+
42+
if sendmailStatus != {}:
43+
print('There was a problem sending email to %s: %s' % (email,sendmailStatus))
44+
45+
smtpObj.quit()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
#! /usr/bin/python3.5
2+
3+
4+
"""
5+
6+
Author: Samrat Banerjee
7+
Dated: 10/09/2018
8+
Description: Project: Defines the textmyself() function that texts a message passed to it as a string.
9+
10+
"""
11+
12+
# Preset values:
13+
accountSID = 'ACxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
14+
authToken = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx'
15+
myNumber = '+15559998888'
16+
twilioNumber = '+15552225678'
17+
18+
from twilio.rest import TwilioRestClient
19+
20+
def textmyself(message):
21+
twilioCli = TwilioRestClient(accountSID, authToken)
22+
twilioCli.messages.create(body=message, from_=twilioNumber, to=myNumber)
23+

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,6 @@
3434
* [x] Chapter 13 – Working with PDF and Word Documents
3535
* [x] Chapter 14 – Working with CSV Files and JSON Data
3636
* [x] Chapter 15 – Keeping Time, Scheduling Tasks, and Launching Programs
37-
* [ ] Chapter 16 – Sending Email and Text Messages
37+
* [x] Chapter 16 – Sending Email and Text Messages
3838
* [ ] Chapter 17 – Manipulating Images
3939
* [ ] Chapter 18 – Controlling the Keyboard and Mouse with GUI Automation

0 commit comments

Comments
 (0)