mail-parser icon indicating copy to clipboard operation
mail-parser copied to clipboard

Ignore warnings - Email content 'calendar' not handled

Open georgearun opened this issue 2 years ago • 4 comments

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.

georgearun avatar Dec 08 '21 09:12 georgearun

I am looking for a way to stop this warning from displaying in my code.

georgearun avatar Dec 08 '21 09:12 georgearun

I have a similar issue. I tried using shutup but with no success.

kuleje avatar Dec 14 '22 15:12 kuleje

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

j-adamczyk avatar Apr 11 '23 16:04 j-adamczyk

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()

calderwoodra avatar Oct 28 '23 23:10 calderwoodra