Python Program to Merge Mail

# Contents of Names.txt
Jack
Rosh

# Contents of Body.txt
Greetings!
This is to invite you to attend the new Product launch event at Microsoft London on 10 October 2019.

Looking forward to your participation.

Registration Fees: $20

Thanks and Regards,

Program:

with open("Names.txt",'r') as Names:
with open("Body.txt",'r') as Body:
text=Body.read()
for name in Names:
msg="Hello"+name+text
with open(name.strip()+".txt",'w')as File:
File.write(msg)

Output:
# Contents of Jack.txt
Hello Jack
Greetings!
This is to invite you to attend the new Product launch event at Microsoft London on 10 October 2019.

Looking forward to your participation.

Registration Fees: $20

Thanks and Regards,

# Contents of Rose.txt
Hello Rose
Greetings!
This is to invite you to attend the new Product launch event at Microsoft London on 10 October 2019.

Looking forward to your participation.

Registration Fees: $20

Thanks and Regards,