I am currently using this code to generate an email with Python:
from email import generator
from email.mime.multipart import MIMEMultipart
from email.mime.text import MIMEText
def Create_Email():
msg = MIMEMultipart('alternative')
msg['Subject'] = 'My Subject'
msg['To'] = 'test@gmail.com'
html = """\
<html>
<head></head>
<body>hello world</body>
</html>"""
part = MIMEText(html, 'html')
msg.attach(part)
outfile_name = r'C:\Downloads\email_sample.eml'
with open(outfile_name, 'w') as outfile:
gen = generator.Generator(outfile)
gen.flatten(msg)
Create_Email()
But when I then open the file with outlook, it appears as an already-sent email:
How can I change this so that the saved file will be treated as a draft, which I can still edit and then send? Like so:
If email.generator
cannot do this, I'd be happy to use an alternative package.