I am working on a project that needs to intake large amounts of emails (stored as text files) and remove their headers for parsing to another function. I am using the email.parser package and the get_body function is not working getting an attribute error that decode is not found.
for file in files:
if file.endswith(".txt"):
f = open(os.path.join(root, file))
file_content = f.read()
msg=email.message_from_string(file_content, policy=email.policy.default,decode=True)
The error happens on the msg line and will not allow me to go further. I have used other methods but they do not allow me to use the get_body function
The error: TypeError: init() got an unexpected keyword argument 'decode'