Home > other >  How can I change Image in the URL and still make sure old emails that are sent is not affected?
How can I change Image in the URL and still make sure old emails that are sent is not affected?

Time:11-03

Our application will send the emails for customers on different events. These emails has placeholder where we need to display a promotion banner. Marketing team asking us to make this as dynamic. That means there will be a common url, and team will change the image in that URL for every month whenever new promotion comes in.

Now my requirement is, Say Dec 01 2021, Marketing team has updated a new image in that URL.

  1. Now all my emails that will send after Dec 01 2021 should have this new image.

  2. Also, All the Emails that are already sent to customer before Dec 01 2021 (until Nov 30 2021) should not get affected and if customer opens them, they should still see the old image only.

(Note: Both new and old emails will have same IMAGE URL, but only image in that URL will be changed). All our applications are .NET applications.

CodePudding user response:

Twilio SendGrid developer evangelist here.

As Nick and Caius have said in the comments, you cannot achieve this with a single URL. If you change the image behind a URL, then old emails that use that URL will update with the new image when they are opened.

Instead you should either use different URLs each time. Or, as Caius points out, embedded image URLs may not load. So, you can also attach the image to the email and embed it. Base 64 embedding is useful, but it does bloat the email size, especially as it bloats the image size itself.

I personally prefer adding images as attachments and then embedding them in the content by referring to them via CID, or Content-ID. The details on how to do that are in this post on embedding images in emails. But the idea is that you give the attachment a cid attribute and then in your HTML refer to that cid in the src attribute of the img tag:

<img src="cid:myimagecid"/>
  • Related