Skip to content Skip to sidebar Skip to footer

Python: How To Get Html Body Of An Email Message Using Poplib?

I am attempting to get the body of an email message using message.get_payload(). However, this only retrieves the text content of the email, even though the original message is in

Solution 1:

From the documentation

get_payload([i[, decode]]) 
    Return the current payload, which will be a list of Message objects when 
    is_multipart() isTrue, or a stringwhen is_multipart() isFalse.

    Withoptional argument i, get_payload() will return the i-th element of 
    the payload, counting from zero, if is_multipart() isTrue.

Usually HTML email is sent as MIME message. There is often a text only copy and a HTML copy. Have you check how many parts you messages has and if you've tried to retrieve other parts?

Post a Comment for "Python: How To Get Html Body Of An Email Message Using Poplib?"