Send Gmail message with image
  • 30 May 2023
  • 1 Minute to read
  • Dark
    Light

Send Gmail message with image

  • Dark
    Light

Article Summary

Gmail doesn't support adding images as Base64 strings inside HTML img tags. Instead, to display images inline with text in Gmail, attach the image to the email using a mixed content type and reference the image(s) inside a img tag.

Untitled

  1. Open the Gmail Send Message step.
  2. In the Content type parameter, write: multipart/mixed; boundary="XXXXboundary text" or multipart/related.
    1. Note: You can replace“XXXXboundary text” with any other text which will be used as the boundary in the multipart/mixed message.
  3. The first section between the defined boundary text in the Content parameter is the HTML-formatted email body. 
  4. Images to be inserted inline with text are referenced by a Content-ID string: src=3D"cid:ii_{{ $.generate_random_string.result }}".
    1. Use the Generate Random String utility step in order to generate unique IDs.
    2. Each image is referenced within the code by both a X-Attachment-Id and a Content-Id
  5. Refer to the below code snippet as an example of what to put in the Content parameter.


This is a multipart MESSAGE_TEXT

--XXXXboundary text
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr">This is image number one<div><img src=3D"cid:ii_{{ $.generate_random_string.result }}" alt=3D"image1.=png"></div><br></div>
<div dir=3D"ltr">This is image number two<div><img src=3D"cid:ii_{{ $.generate_random_string_1.result }}" alt=3D"image2.=png"></div><br></div>

--XXXXboundary text

--XXXXboundary text
Content-Type: image/png; name="image1.png"
Content-Disposition: attachment; filename="image1.png"
Content-Transfer-Encoding: base64
X-Attachment-Id: ii_{{ $.generate_random_string.result }}
Content-ID: <ii_{{ $.generate_random_string.result }}>

{{ BASE64-ENCONDED-IMAGE-1 }}

--XXXXboundary text

--XXXXboundary text
Content-Type: image/png; name="image2.png"
Content-Disposition: attachment; filename="image2.png"
Content-Transfer-Encoding: base64
X-Attachment-Id: ii_{{ $.generate_random_string_1.result }}
Content-ID: <ii_{{ $.generate_random_string_1.result }}>

{{ BASE64-ENCONDED-IMAGE-2 }}

--XXXXboundary text

Was this article helpful?

Changing your password will log you out immediately. Use the new password to log back in.
First name must have atleast 2 characters. Numbers and special characters are not allowed.
Last name must have atleast 1 characters. Numbers and special characters are not allowed.
Enter a valid email
Enter a valid password
Your profile has been successfully updated.