Aug-29-2023, 09:17 PM
Greetings!
I need to send tons of emails, to do that I have to use an HTML file.
The string “ MessageBody” in the HTML file must be replaced with the Message file which has about 250 words and some coma delimited data that .csv file. I thought I could/should use 'fileinput' but I might be wrong.
Here is a snipped for the task and it does not work, error:
replace() argument 2 must be str, not _io.TextIOWrapper
Thank you
I need to send tons of emails, to do that I have to use an HTML file.
The string “ MessageBody” in the HTML file must be replaced with the Message file which has about 250 words and some coma delimited data that .csv file. I thought I could/should use 'fileinput' but I might be wrong.
Here is a snipped for the task and it does not work, error:
replace() argument 2 must be str, not _io.TextIOWrapper
import fileinput relace_with = open('C:/01/File_replace/Email_Body.txt','r') relace_with.close() with fileinput.FileInput('C:/01/File_replace/Template_EM.html') as file: for line in file: line = line.replace("Message", relace_with) print(line) with open('C:/01/File_replace/Template_EM_New.html','w') as nf : nf.write(f"line\n") exitAny help is appreciated.
Thank you