Link to home
Start Free TrialLog in
Avatar of Dirk Haest
Dirk HaestFlag for Belgium

asked on

Email and images

How can I add an image as "invisible" attachment.
I mean: I want to email (through a html-message) a person, which will be personally but I want to add an image in my html-mail ?
How can I do this ?
The first solution i've found myself, but that's not what I want, because then the user has to be able to put a picture an a "webspace" to link it to my message.
I read a lot about using cid, but I don't know how to do it.
I make my mail in visual basic
Avatar of alexwms
alexwms

Hy,
I do hope this is impossible and stays impossible with most clients (Lotus Notes will be an exception like always).  Otherwise we will be flodded with Spam in this style.
Use a normal Text mail and Mime attachments. That's the normal way. Everything else is a hack and unrelayable.
Alexander
Hi there,

to embed your image and not having it shown as attachment create the mail this way:

1. Setting the MIME-type
Setting the MIME-Type to "multipart/related" tells the mailclient that the single MIME-Parts are in relation to each other.

2. Create the HTML-Mail
Generate your Mail-Body using HTML and include the images with the "cid"-Magic you've already heard of:

<html><body>
This ist your image:<img src="cid:image.gif"/>
</body></html>

3. Attach the image
Your image has to be included as a MIME-Part for your Message. Set the header "Content-ID" to "image.gif". (As you might have guessed, Content-ID equals cid). The image is best included in byse64-encoding. Resulting MIME-Part should look like this:

--yourBoundary
Content-Type: image/gif; name="image.gif"
Content-ID: image.gif
Content-Transfer-Encoding: base64

ABascde343242==


I've done this with PHP and JavaMail already. Mailclients that i found to work are Outlook(Express) and Notes 5 (as long as HTML-Mail is enabled)

Hope that helps,

Jan

P.S.: If you have OutlookExpress you can create these kind of mail (with insert image). After sending it to yourself have a look at the message sourcecode (somewhere at File/Properties/Details/Sourcecode).
Avatar of Dirk Haest

ASKER

i've found the solution by myself, so i will let this question close
The solution:
http://www.slipstick.com/dev/code/htmlimg.htm
ASKER CERTIFIED SOLUTION
Avatar of SpideyMod
SpideyMod

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial