0

When I receive email from my bank or, say, Skype, I see their image in the thumbnail along with one line blurb of the email.

How can I get my company logo to show up in the thumbnail when sending email programatically via sparkpost (email sending service) through a nodejs server?

Mark Seemann
  • 225,310
  • 48
  • 427
  • 736
vjjj
  • 1,019
  • 3
  • 10
  • 35

1 Answers1

0

You need to do an inline image. You do that by converting the image to base64 and then including the content in an image tag.

Here is a sample that will send a red dot red dot PNG in an email through SparkPost.

curl -X POST \
  https://api.sparkpost.com/api/v1/transmissions \
  -H 'Authorization: [YOUR_API_KEY_HERE]' \
  -H 'cache-control: no-cache' \
  -d '{
    "options": {
        "open_tracking": true,
        "click_tracking": true
    },
  "campaign_id": "test",
  "recipients": [
    {
      "address": {
        "email": "to@example.com",
        "name": "To recipient"
      }, 
        "tags": []
    }
  ],
  "content": {
    "from": {
      "email": "from@example.com",
      "name": "From address"
    },
    "subject": "My Sample Subject",
    "text": "Test",
    "html": "<p>Test</p> <img src=\"data:image/png;base64, iVBORw0KGgoAAAANSUhEUgAAAAUAAAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO9TXL0Y4OHwAAAABJRU5ErkJggg==\" alt=\"A Red dot\" />"
  }
}

'

There are lots of ways to convert images to base64 but here is one example: https://www.base64-image.de/

Yepher
  • 1,465
  • 12
  • 25
  • Yepher, I want something like this - https://imgur.com/a/Knh1nQy (email preview on outlook.com) – vjjj Dec 04 '18 at 00:35