method that returns the email' body as value of the bytes data type (the bytes data type is beyond the scope of this book but this still isn' string value that we can use ughthe last step is to call the decode(method on the bytes value returned by get_payload(the decode(method takes one argumentthe message' character encodingstored in the text_part charset or html_part charset attribute thisfinallywill return the string of the email' body continue the interactive shell example by entering the followingu message text_part !none true message text_part get_payload(decode(message text_part charsetv 'so longand thanks for all the fish!\ \ \ \ -al\ \nw message html_part !none true message html_part get_payload(decode(message html_part charset'so longand thanks for all the fish!-al \ \nthe email we're working with has both plaintext and html contentso the pyzmessage object stored in message has text_part and html_part attributes not equal to none calling get_payload(on the message' text_part and then calling decode(on the bytes value returns string of the text version of the email using get_payload(and decode(with the message' html_part returns string of the html version of the email deleting emails to delete emailspass list of message uids to the imapclient object' delete_messages(method this marks the emails with the \deleted flag calling the expunge(method permanently deletes all emails with the /deleted flag in the currently selected folder consider the following interactive shell exampleu imapobj select_folder('inbox'readonly=falsev uids imapobj search(['on -jul- ']uids [ imapobj delete_messages(uidsw { ('\\seen''\\deleted')imapobj expunge(('success'[( 'exists')]here we select the inbox by calling select_folder(on the imapclient object and passing 'inboxas the first argumentwe also pass the keyword argument readonly=false so that we can delete emails we search the inbox for messages received on specific date and store the returned message ids in uids calling delete_message(and passing it uids returns dictionaryeach key-value pair is message id and tuple of the message'