0

I am currently trying to write a function which will create a mail and then displayed it through Outlook. Like this the user will be able to create and see his new mail under Outlook, and just decide to click on Send or not.

I struggle to find an attribute to smtplib, or an attribute to Mimemultipart like smtplib.display() or

msg = MIMEMultipart('alternative') 
msg = email.message.Message() 
msg.display(True).

I already succesfully create and send automatically mail with smtplib. What I can't find on the web, is this attribute to display the crated mail.....

What I have:

def createEmailConfirmation():

    email_content  = """\
        <!DOCTYPE html><html lang="en">
        <head>
        <meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
        </head>
            <body>
                <div class="table-responsive">
                    <table class="table table-bordered m-b-0">
                        <thead>
                            <tr>
                                <th> Title </th>
                            </tr>
                        </thead>
                        <tbody>
                            <tr>
                                <td> Confirmation </td>
                            </tr>
                        </tbody>
                    </table>
                </div>
            </body>
        </html>
        """     

    msg = MIMEMultipart('alternative')
    msg = email.message.Message()
    msg['Subject'] = 'Confirmation Mail'

    toaddr = ['useraddressmail@test.com']
    bcc = ['']
    cc = ['']

    fromaddr = ''other_useraddressmail@test.com'

    toaddrs = toaddr + cc + bcc
    password = "password"
    msg.add_header('Content-Type', 'text/html')
    msg.set_payload(email_content)
    s = smtplib.SMTP('**.***.**.**')
    s.set_debuglevel(False) # show communication with the server
    msg.display

I think it something really easy, that will only fit In one line but I can't find it...

Best Regards,

  • hey, check https://stackoverflow.com/q/20956424/8150371 – Stack Jun 18 '18 at 12:59
  • Hi, Thanks for your reply, I saw this post, but it's using the library "import win32com.client as win32 ", and I don't have it. I would prefer to stay with SMTP or MIMEmultipart if possible. But I don't know if it exists.. – lekisscoolfr Jun 18 '18 at 13:12
  • check this answer to install win32com `https://stackoverflow.com/q/23864234/8150371`. – Stack Jun 18 '18 at 13:15

0 Answers0