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

Time:11-29

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 [email protected]'
   mailItem.Cc = 'others [email protected]'
   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()

CodePudding user response:

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

  • Related