- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Feb 02, 2025 06:05 PM
Hi all,
I want to expand a script that assembles an e-mail using a few field values and sends a nice and simple daily report to stakeholder.
I want to add images inline from an attachment-type field. I use something like this:
if (clippings && clippings.length > 0) {
for (let clip of clippings) {
let imageUrl = clip.url;
imageUrl = clip.thumbnails.large.url;
and later:
if (imageUrl) {
entryText += `<br><img src='${imageUrl}' alt='Clipping' style='max-width: 100%; height: auto;' /><br>`;
console.log(`thumbnail added: ${encodedUrl}`);
}
I then pass my output over to the next step:
outputText += `${entryText}<br><br>`;
output.set("emailOutput", outputText);
Although all URLS are definitely good (I paste them into the browser and the thumbnail shows), in the generated e-mail, only a few of them are displayed correctly as images. For most of them, a fragment of the URL shows up in the e-mail body. Even more strange, when I tested different code (i.e. markdown vs. HTML), suddenly other images are shown, while those that had worked before were now gone.
Could it be it is just not possible without moving the images to a public-facing service?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Feb 02, 2025 07:14 PM
Ah yeah I encountered something similar where some of the image URLs had a format that's being confused with markdown, e.g. 'www.test.com/new_article_url', where the underscores would be used for italics or something
Try putting just the links themselves into a preview to see whether that's the case and then identify the patterns from there, and then try generating a preview of the email with the links manually created with either markdown or HTML to confirm stuff?
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎Feb 03, 2025 06:11 AM
Thanks Adam, this was the critical advice I needed. We need to escape markdown, so I used this instead:
let safeUrl = encodedUrl.replace(/_/g, '\\_');
entryText += `<br><img src='${safeUrl}' alt='Clipping' style='max-width: 100%; height: auto;' /><br>`;
Thanks again!
