Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit b7a58bf

Browse files
Merge pull request avinashkranjan#635 from SpecTEviL/AutoBDayWisher-GSSoC'21#623
Added Auto B'day Wisher - gssoc'21 avinashkranjan#623
2 parents 222d353 + 746e73f commit b7a58bf

File tree

4 files changed

+84
-0
lines changed

4 files changed

+84
-0
lines changed
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
import pandas as pd # Pandas library is used for importing and reading the data
2+
import datetime # datetime module is used for fetching the dates
3+
import smtplib # smtp library used for sending mail
4+
import os
5+
6+
current_path = os.getcwd()
7+
print(current_path)
8+
os.chdir(current_path) # Changing the Path of the directory in which you are currently working
9+
10+
GMAIL_ID = input("Enter your email: ") # Give your mail here from which you want to send the wishes
11+
GMAIL_PSWD = input("Enter password for your email mentioned above: ") # Give your mail password
12+
13+
14+
def sendEmail(to, sub, msg):
15+
print(f"Email to {to} sent: \nSubject: {sub} ,\nMessage: {msg}")
16+
s = smtplib.SMTP('smtp.gmail.com', 587) # creating server to send mail
17+
s.starttls() # start a TLS session
18+
s.login(GMAIL_ID, GMAIL_PSWD) # the function will login with your Gmail credentials
19+
s.sendmail(GMAIL_ID, to, f"Subject: {sub} \n\n {msg}") # sending the mail
20+
s.quit()
21+
22+
23+
if __name__ == "__main__":
24+
df = pd.read_excel("data.xlsx") # the datasheet where the data of the friends is stored
25+
today = datetime.datetime.now().strftime("%d-%m")
26+
yearNow = datetime.datetime.now().strftime("%Y")
27+
28+
writeInd = []
29+
for index, item in df.iterrows():
30+
bday = item['Birthday']
31+
bday = datetime.datetime.strptime(bday, "%d-%m-%Y")
32+
bday = bday.strftime("%d-%m")
33+
if(today == bday) and yearNow not in str(item['LastWishedYear']):
34+
sendEmail(item['Email'], "Happy Birthday", item['Dialogue']) # calling the sendmail function
35+
writeInd.append(index)
36+
37+
if writeInd != None:
38+
for i in writeInd:
39+
oldYear = df.loc[i, 'LastWishedYear']
40+
df.loc[i, 'LastWishedYear'] = str(oldYear) + ", " + str(yearNow)
41+
42+
df.to_excel('data.xlsx', index=False)

‎Auto Birthday Wisher/README.md‎

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# Auto Birthday Wisher
2+
3+
One forgets to send birthday wishes to friends many times. At such times an automatic birthday wisher comes handy. An automatic birthday wisher via email makes one's life easy. It will send the birthday wishes to friends via email automatically via a server and using an excel sheet to store the data of friends and their birthdays along with email id. It'll send the wishes to friends for all the upcoming years untill we stop the server.
4+
5+
## Setup instructions
6+
7+
In order to run this script, You just need the following modules:
8+
9+
- **Pandas** is a fast, powerful, flexible and easy to use open source data analysis and manipulation tool,
10+
built on top of the Python programming language.
11+
```bash
12+
pip install pandas
13+
```
14+
15+
- **Datetime** is a module used for Encapsulation of date/time values.
16+
```bash
17+
pip install DateTime
18+
```
19+
20+
- **smtplib** module defines an SMTP client session object that can be used to send mail to any Internet machine with an SMTP or ESMTP listener daemon.
21+
22+
## Configuration
23+
1. Assign the Gmail Id of sender to the GMAIL_ID variable in *line 10* of **"Auto B'Day Wisher.py"** file. (e.g. 'xyz@gmail.com')
24+
2. Similar to first step assign the Gmail password of sender to the GMAIL_PSWD variable in *line 11* of **"Auto B'Day Wisher.py"** file. (e.g. '1234')
25+
3. In **"data.xlsx"** file insert the name of the receiver in second column under *Name*. Similarly update the **Birthday** field with the birth date of receiver in the given format*("%dd-%mm-%YYYY")*. Update the **Dailogue** field with a short message you want to send and the **Email** field with the email of the receiver.
26+
4. Make sure to give permission to your google account from which you're sending email to **Allow less secure apps**. Just turn this *"ON"* from [here](https://support.google.com/accounts/answer/6010255?hl=en#zippy=%2Cif-less-secure-app-access-is-off-for-your-account).
27+
5. Run the command
28+
```bash
29+
python "Auto B'Day Wisher.py"
30+
```
31+
32+
## Screenshots
33+
34+
<p align="center">
35+
<img src="https://raw.githubusercontent.com/SpecTEviL/Amazing-Python-Scripts/AutoBDayWisher-GSSoC'21%23623/Auto%20Birthday%20Wisher/emailReceived.jpg" height="700" alt="Email received by friend"/>
36+
<br>
37+
Birthday Wishes received by the Friend via Email
38+
</p>
39+
40+
## Author
41+
42+
[Vishal Patil](https://github.com/SpecTEviL)

‎Auto Birthday Wisher/data.xlsx‎

5.02 KB
Binary file not shown.
181 KB
Loading[フレーム]

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /