From d4ea28d5684933c02385bcc70a6340fa61d997a9 Mon Sep 17 00:00:00 2001 From: ritika123-123 <66022932+ritika123-123@users.noreply.github.com> Date: Thu, 1 Oct 2020 21:47:56 +0530 Subject: [PATCH] margemails python program to merge mails --- mergemails | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 mergemails diff --git a/mergemails b/mergemails new file mode 100644 index 0000000..6c6979f --- /dev/null +++ b/mergemails @@ -0,0 +1,20 @@ +# Python program to mail merger +# Names are in the file names.txt +# Body of the mail is in body.txt + +# open names.txt for reading +with open("names.txt",'r',encoding = 'utf-8') as names_file: + + # open body.txt for reading + with open("body.txt",'r',encoding = 'utf-8') as body_file: + + # read entire content of the body + body = body_file.read() + + # iterate over names + for name in names_file: + mail = "Hello "+name+body + + # write the mails to individual files + with open(name.strip()+".txt",'w',encoding = 'utf-8') as mail_file: + mail_file.write(mail)