Send Gmail message with image
- 30 May 2023
- 1 Minute to read
- DarkLight
Send Gmail message with image
- Updated on 30 May 2023
- 1 Minute to read
- DarkLight
Article Summary
Share feedback
Thanks for sharing your feedback!
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.
- Open the Gmail Send Message step.
- In the Content type parameter, write:
multipart/mixed; boundary="XXXXboundary text"
ormultipart/related
.- Note: You can replace“XXXXboundary text” with any other text which will be used as the boundary in the multipart/mixed message.
- The first section between the defined boundary text in the Content parameter is the HTML-formatted email body.
- Images to be inserted inline with text are referenced by a Content-ID string:
src=3D"cid:ii_{{ $.generate_random_string.result }}"
.- Use the Generate Random String utility step in order to generate unique IDs.
- Each image is referenced within the code by both a X-Attachment-Id and a Content-Id
- 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?