Tuesday, February 21, 2012

email - inline image

Hello djangos,

I want to add a *.jpg image to an html-formated/email signature.

I am not sure if this approach is correct, please help:

image_file = open(settings.PROJECT_ROOT+'/static/images/image_name.jpg', 'rb') #get the image file
msg_image = MIMEImage(image_file.read())                                                                            #with proper MIME type
image_file.close()
msg.attach(msg_image)                                                                                                            #attach the image to the mail message.

so far so good:
the image gets sent with the email message and is attached as "attachment.dat".

How can I reference this image now to see it appear inline in the mail message!?

<IMG SRC="???/image_name.jpg" ALIGN="bottom" BORDER="0">

Please improve my code...
why is the image recognized as "attachment.dat" and not with proper image_name???

Is this the right approach to send a signature with inline image?

Thanks for your help guys
ionic






No comments:

Post a Comment