mail-parser
mail-parser copied to clipboard
Ignore warnings - Email content 'calendar' not handled
I'm getting the following warning while reading .eml files "Email content 'calendar' not handled".
Code - mailparser.parse_from_file("ujk9148.eml")
. This file contains calendar invites due to which warnings are displayed, due to which is affecting the performance of the code.
warnings.filter("ignore")
also does not suppress this issue. Is there any way to disable this particular warning/issue.
I am looking for a way to stop this warning from displaying in my code.
I have a similar issue. I tried using shutup but with no success.
Any way for turning off warnings would be very useful. For cleaning large corpora of email texts, I get incredibly large logs due to those warnings
If you don't care about the content in those parts, you can remove it with the following snippet:
eml_message = email.message_from_string(body)
for part in eml_message.walk():
if part.get_content_type() == 'text/calendar':
part.set_payload('')
elif part.get_content_type() == 'text/x-amp-html':
part.set_payload('')
elif part.get_content_type() == 'text/rfc822-headers':
part.set_payload('')
body = eml_message.as_string()