18

Can an HTML email use an image attachment as the source for tag?

Let's say I am sending an email with per-email specific images - and they are sent as an attachment to the email - can the HTML body within the email use the those images? My guess would be no, but are there any hacks or workarounds that would make it work?

Thanks,

Goro
  • 9,919
  • 22
  • 74
  • 108

1 Answers1

25

No hacks needed. Use the cid: URI scheme

 --boundary-example 1
 Content-Type: Text/HTML; charset=US-ASCII

 to the other body part, for example through a statement such as:
 <IMG SRC="cid:foo4*foo1@bar.net" ALT="IETF logo">

 --boundary-example-1

 Content-ID: <foo4*foo1@bar.net>
 Content-Type: IMAGE/GIF
 Content-Transfer-Encoding: BASE64

 R0lGODlhGAGgAPEAAP/////ZRaCgoAAAACH+PUNvcHlyaWdodCAoQykgMTk5
 NSBJRVRGLiBVbmF1dGhvcml6ZWQgZHVwbGljYXRpb24gcHJvaGliaXRlZC4A
 etc...

 --boundary-example-1--
Community
  • 1
  • 1
Quentin
  • 914,110
  • 126
  • 1,211
  • 1,335
  • I take it the carets are necessary? Content-ID: **<** name **>** – Jonathan Jun 03 '15 at 04:52
  • 1
    from the documentation linked to in the answer: "Notes: In Internet mail messages, the addr-spec in a Content-ID [MIME] or Message-ID [822] header is enclosed in angle brackets (<>)." – Quentin Jun 03 '15 at 08:55
  • why is the data in base64? It is user defined and needed, or can it be different or inrelevent in that case? – Sandburg Nov 07 '18 at 15:01