Does anybody know how to send an smtp email with inline image. ie to display the image in the body and not as attachment.
Format the message as html and put it in BodyHTML.
But how do i put the local image to the htmlBody. I don’t have any place to host the image.
You need to open the picture and Base64Encode it.
Then I think you should put it in an img tag.
<img src="data:image/png;base64,your_encoded_image" width="32" height="32">
Albin is correct.
i tried it, unfortunately its not working. in the body area there shows a x mark for picture. but the actual picture in not showing.
Make sure you pass 0 to EncodeBase64 for the linewrap length.
See also this discussion (linked from the above discussion) about support for embedded images in various email clients. It doesn’t look good. Better to go with Daniel Taylor’s EmailMessage replacement.
As usual, the spammers screwed it up for the rest of us.
Can anyone show how to implement the Daniel Taylor’s EmailMessageTD replacement. I downloaded the .rbo file, but there is no example in that.
Christian of MBS,
Does you CURL class have a solution for this.
For anyone looking for solution, please use CURLMBS class from MonkeyBreadSoftware. It perfectly send an inline image for emails.
An option is to build the email entirely yourself. I was looking for a shell script I had once made but I can’t find it. It’s laborious but easily automatable.
The trick is that the images are parts of the multi-part MIME message, and they have unique Content-ID codes for each. These can be called in the HTML version of the body text as normal images: .
If I can find the actual script I’ll post it. I may try to automate into Xojo as well, although I bet there’s plenty of implementations for this already. For me this shell script (made several years ago) works perfectly every time.
Also, keep in mind that these implementations are not standard. gmail, outlook and mail.app all have their own ways of dealing with this and, more important, their own quirks. For example, gmail will not accept and if you use single quotes instead of double quotes. As Tim says, what little could be considered “standard” has been so abused by spammers that it’s very unreliable by now. Sending mails with large pictures is as sure to trigger someone’s spam filter as just sending a single URL without any more text.