4

I cannot get thunderbird to show any embedded images I send in emails via python. It shows small empty boxes in the image and the image underneath the body (not a typical attachment).

the emails are correct in Outlook and Yahoo.

I must be missing a header?

self.msg = MIMEMultipart( )
fp       = open( path2img , 'rb')
msgImage = MIMEImage(fp.read())
fp.close()
msgImage.add_header('Content-ID', '<imagename>')
msgImage.add_header('Content-Disposition' , 'inline' , filename='image.png')
msgImage.add_header('Content-Type' , 'image/png')
self.msg.attach(msgImage)

my image source in the email body is:

<img src="cid:imagename">

I have looked everywhere and cannot work out why!! please help.

(my Python might not be great, but good enough for Outlook / Yahoo)

thanks in advance

old_timer
  • 69,149
  • 8
  • 89
  • 168
Gordon
  • 393
  • 1
  • 3
  • 8
  • Thunderbird must be blocking all images may be.. . like security issues.. . check out for show images/its safe kind of options.. . – codersofthedark Nov 25 '11 at 19:16

2 Answers2

1

You need to refer to the 'filename' value, not the Content-ID. For instance:

<img src="cid:image.png"/>

See this question for more info: Display an attached image on the HTML message

Community
  • 1
  • 1
David K. Hess
  • 16,632
  • 2
  • 49
  • 73
0

I had the same issue. Just change the MIMEMultipart constructor to:

self.msg = MIMEMultipart('related')

and it will work.

Derek Farren
  • 127
  • 1
  • 6