Sending HTML mail including image with Pharo

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

Sending HTML mail including image with Pharo

Torsten Bergmann
Hi,

when I send a mail using Pharo it works for basic text. It also
works for HTML by using "alternative part".

| mailMessage |
mailMessage := MailMessage empty.
mailMessage setField: 'subject' toString: 'HelloWorld'.
mailMessage addAlternativePart: self someHTML contentType: MIMEDocument contentTypeHtml.
mailMessage addAlternativePart: self someText contentType: MIMEDocument contentTypePlainText.

Then sending the mail using ZdcSecureSMTPClient.

Now I want to add an image to the html mail. Inlining the image using base 64 and

< img src="data:image/png;base64,iVBORw0KGgoA ...">

does not work.

According to Stackoverflow [1] the image has to be embedded in the message as an
attachment and given a CID:

<img src="cid:0123456789">

Before I try to fight with current MailMessage implementation myself: anyone did that
before and can provide an easy example?

Thx
T.

[1] http://stackoverflow.com/questions/9110091/base64-encoded-images-in-email-signatures