Mrc Rblr
Mrc Rblr

Reputation: 7

why others recipients are not able to see the image from my html? using win32 python

Hello guys i'm tryng to send an image in my html, when im testing sending it to myself is working fine But, if try to send to other recepients they don't receive it how can i fix that: any suggestion, thank you

my code is this:

   import win32com.client as win32

   olApp = win32.Dispatch('Outlook.Application')
   olNS = olApp.GetNameSpace('MAPI')


   mailItem = olApp.CreateItem(0)
   mailItem.Subject = 'test daily Email'
   mailItem.BodyFormat = 1
   mailItem.To = 'testing it with my myself@outlook.com'
   mailItem.Cc = 'others recepient@outlook.com'
   mailItem.htmlBody = '''\
        <html>
        <body>

        <h2>This is just a test</h2>

        <p>Using it for test before production</p>

        <img src="E:\\html5.gif" alt="HTML5 Icon" style="width:128px;height:128px;">

        </body>
        </html>
        '''


   mailItem.Save()
   mailItem.Send()

Upvotes: 0

Views: 416

Answers (1)

Dmitry Streblechenko
Dmitry Streblechenko

Reputation: 66316

They do see the image because they cannot possibly have access to your local file (E:\html5.gif).

You need to add the image as an attachment and set its content-id appropriately, then reference the image by that content id in your HTML.

See https://stackoverflow.com/a/28272165/332059

Upvotes: 0

Related Questions