Skip to main content

How to Include Unique Images in each Email Message

This guide describes how you can dynamically insert inline images in your email body and the images are different for each receipt of mail merge.

We'll upload our images to an external image hosting site and then insert direct links to the uploaded image in our email campaign using the variable fields.

Copy Image Address

Upload Images​

Go to imgur.com and upload the image(s) from your computer. Right-click the uploaded image and choose Copy Image Address from the contextual menu to grab the direct link of your image.

Switch to your Google Sheet and create a new column and give it some name - say Web Images. Paste the URL (link) of all the uploaded images in this column, one per row.

Sheet Images

tip

You can even upload images to Google Photos and use the embed tool to generate direct links that can be embedded in your email body.

Create Image Tags​

Next, create another column in the Google Sheet and paste the following Array Formula in the first cell of this new column.

=ArrayFormula(
IF(ROW(C:C)=1,"Image Tag",
IF(ISBLANK(C:C),"",
SUBSTITUTE("<img src='URL' />","URL",C:C)
)
)
)

The formula basically takes all image URLs that are present in column C and turns them in HTML <img>. The first cell of the column it titled "Image Tag" but you can rename that in the formula to use a different name.

Image Formula for Google Sheets

Next, edit the email template of your mail merge and add a new variable field in the email body that is titled {{Image Tag}}. If you have renamed the image column in the previous step, use that exact name here.

When the campaign is sent, the marker in the template will be replaced with inline images and each image would be different and unique through they are sent from the same campaign.

Image Preview​

You can use the IMAGE function to preview the images before including them in your merge campaign.

Image preview

Adjust Image Size​

The images are always inserted in the email body using the original dimension of the uploaded file. However, if you wish to limit the size of your embedded images, the <img> tag should be modified to specify a maximum width (in pixels).

=ArrayFormula(
IF(ROW(C:C)=1,"Image Tag",
IF(ISBLANK(C:C),"",
SUBSTITUTE("<img src='URL' style='max-width:500px' />", "URL" ,C:C)
)
)
)

The above formula will shrink images that are wider than 500 pixels. The height of the image will be changed automatically to preserve the original aspect ratio.