Skip to content

Commit 3d9f4aa

Browse files
author
codehouseindia
authored
Merge pull request codehouseindia#500 from Naved2019khan/patch-1
Create Source Code to Merge Mails
2 parents 9a8ee39 + 061427f commit 3d9f4aa

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Source Code to Merge Mails

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
# Python program to mail merger
2+
# Names are in the file names.txt
3+
# Body of the mail is in body.txt
4+
5+
# open names.txt for reading
6+
with open("names.txt",'r',encoding = 'utf-8') as names_file:
7+
8+
# open body.txt for reading
9+
with open("body.txt",'r',encoding = 'utf-8') as body_file:
10+
11+
# read entire content of the body
12+
body = body_file.read()
13+
14+
# iterate over names
15+
for name in names_file:
16+
mail = "Hello "+name+body
17+
18+
# write the mails to individual files
19+
with open(name.strip()+".txt",'w',encoding = 'utf-8') as mail_file:
20+
mail_file.write(mail)

0 commit comments

Comments
 (0)