I have an email that I'm reading with the Python email lib that I need to modify the attachments of. The email Message class has the "attach" method, but does not have anything like "detach". How can I remove an attachment from a multipart message? If possible, I want to do this without recreating the message from scratch.
Essentially I want to:
Delete an attachment from a sent or received email messageYou cannot remove attachments from multiple messages at once. Open the email message in the reading pane or double-click the message to open it in a new window. Select the drop-down arrow next to the attachment name and then select Remove attachment.
Highlight the file and press the Del . Right-click the attachment and select delete from the right-click menu.
It is the base class for the email object model. EmailMessage provides the core functionality for setting and querying header fields, for accessing message bodies, and for creating or modifying structured messages. An email message consists of headers and a payload (which is also referred to as the content).
In Python, set_payload is a method of the class email.message.Message()
The way I've figured out to do it is:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With