I have a list in which there are 2 values. I want to send mail with that list value but every time it is sending a separate mail for each value.
List is:-
file_list = ['D:/Users/SPate233/Downloads/NS dashboard/sql_query\\Book1.csv', 'D:/Users/SPate233/Downloads/NS dashboard/sql_query\\Book2.csv']
Sample code:-
for names in file_list:
body = "Hi Team, \n\n NS_Dashboard_FieldExecution script failed due to some reason. " \
"\n Please check the attached log file.\n Empty Files :- \n %s" %names + \
"\n\n Thanks & Regards, \n NS_Dashboard_FieldExecution Team"
emailstr = "echo '{0}' | /bin/mail -a {1} -s '{2}' '{3}'".format(body, msg_tran, sub, receiver)
os.system(emailstr)
Output:-
I want a single mail with the name of both the value of the list. like this:-
Hi Team,
NS_Dashboard_FieldExecution script failed due to some reason.
Please check the attached log file.
Empty Files :-
D:/Users/SPate233/Downloads/NS dashboard/sql_query\\Book1.csv
D:/Users/SPate233/Downloads/NS dashboard/sql_query\\Book2.csv
Thanks & Regards,
NS_Dashboard_FieldExecution Team