Home  >  Q&A  >  body text

Embed attached images in HTML emails

<p>If I attach an image to an email, how do I place it within the HTML content? I tried using just the filename as the image source but that doesn't seem to work. </p>
P粉285587590P粉285587590422 days ago484

reply all(2)I'll reply

  • P粉614840363

    P粉6148403632023-08-25 12:27:00

    The image attachment part requires Content-ID

    --T4nu9J8b
    Content-Type: image/png
    Content-ID: <idname>
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment ;filename="testimage.png"
    
    iVBORw0KGgoAAAANS...
    --T4nu9J8b--

    Embed it in the markup using the same Content-ID (without the angle brackets)

    <img alt="Embedded Image" src="cid:idname"/>

    This should allow additional images to be displayed in HTML!

    reply
    0
  • P粉450079266

    P粉4500792662023-08-25 00:02:53

    More specific instructions on how to build HTML email messages.

    The result will be a multipart MIME message containing a text/html part (if you do use an alternative part of type text/plain) and multiple images, which are then referenced from the HTML.

    See RFC 1813 and RFC 2378 for more information about content-ids and related data (referenced by CIDs in HTML source code) in mixed MIME.

    reply
    0
  • Cancelreply