creating new ones from scratch in both casesemail can automatically handle details like content encodings ( attached binary images can be treated as text with base encoding and decoding)content typesand more message objects since the email module' message object is at the heart of its apiyou need cursory understanding of its form to get started in shortit is designed to reflect the structure of formatted email message each message consists of three main pieces of informationtype content type (plain texthtml textjpeg imageand so on)encoded as mime main type and subtype for instance"text/htmlmeans the main type is text and the subtype is html ( web page)"image/jpegmeans jpeg photo "multipart/mixedtype means there are nested parts within the message headers dictionary-like mapping interfacewith one key per mail header (fromtoand so onthis interface supports almost all of the usual dictionary operationsand headers may be fetched or set by normal key indexing content "payload,which represents the mail' content this can be either string (bytes or strfor simple messagesor list of additional message objects for multipart container messages with attached or alternative parts for some oddball typesthe payload may be python none object the mime type of message is key to understanding its content for examplemails with attached images may have main top-level message (type multipart/mixed)with three more message objects in its payload--one for its main text (type text/plain)followed by two of type image for the photos (type image/jpegthe photo parts may be encoded for transmission as text with base or another schemethe encoding typeas well as the original image filenameare specified in the part' headers similarlymails that include both simple text and an html alternative will have two nested message objects in their payloadof type plain text (text/plainand html text (text/html)along with main root message of type multipart/alternative your mail client decides which part to displayoften based on your preferences simpler messages may have just root message of type text/plain or text/htmlrepresenting the entire message body the payload for such mails is simple string they may also have no explicitly given type at allwhich generally defaults to text/plain some single-part messages are text/htmlwith no text/plain alternative--they require web browser or other html viewer (or very keen-eyed user client-side scripting