from email.mime.multipart import MIMEMultipart from email.mime.text import MIMEText msg = MIMEMultipart() msg['Subject'] = 'Daily Report' msg['From'] = '[email protected]' msg['To'] = '[email protected]' # Adding plain text as body text = MIMEText('Hello, here is your daily report.') msg.attach(text) # Attach a file file = MIMEText(open('report.txt').read()) file.add_header('Content-Disposition', 'attachment', filename='report.txt') msg.attach(file) # Finally, send the message smtp.send_message(msg)In this example, we create a MIMEMultipart message with a subject and body text, and attach a file to it. The `MIMEMultipart` class provides the `attach()` method to add different types of MIME messages such as `MIMEText` for plain text or `MIMEImage` for images to the message. The `add_header()` method is used to add headers to the attachment such as the filename. The `email` package is part of the Python standard library, and so does not require installation.