NetTalk Central

Author Topic: Sending mail using Postmark API  (Read 688 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 380
    • View Profile
    • Email
Sending mail using Postmark API
« on: December 20, 2024, 02:11:11 AM »
Hi Bruce

Many thanks for your help last night in the NT user group, invaluable sessions,
I certainly learned a few things.

I had one other question about inline images for the HTML body, is using NetEmailSend the only way to do this?
If yes, then my plan was to create a dummy NetEmailSend object, load the HTML string, do the EmbedImages, and then move the HTML string out again with the images embedded.

Postmark has an alternative, in that if the CID is specified in the HTML and the image is on the attachment list,
then it would do the embedding of inline images when the Postmark server processes the email.
But not sure how to handle the CID creation


Any thoughts are appreciated.

thanks
Johan



{
  "From": "sender@example.com",
  "To": "receiver@example.com",
  "Cc": "copied@example.com",
  "Bcc": "blind-copied@example.com",
  "Subject": "Test",
  "Tag": "Invitation",
  "HtmlBody": "<b>Hello</b> <img src=\"cid:image.jpg\"/>",
  "TextBody": "Hello",
  "ReplyTo": "reply@example.com",
  "Headers": [
    {
      "Name": "CUSTOM-HEADER",
      "Value": "value"
    }
  ],
  "TrackOpens": true,
  "TrackLinks": "None",
  "Attachments": [
    {
      "Name": "readme.txt",
      "Content": "dGVzdCBjb250ZW50",
      "ContentType": "text/plain"
    },
    {
      "Name": "report.pdf",
      "Content": "dGVzdCBjb250ZW50",
      "ContentType": "application/octet-stream"
    },
    {
      "Name": "image.jpg",
      "ContentID": "cid:image.jpg",
      "Content": "dGVzdCBjb250ZW50",
      "ContentType": "image/jpeg"
    }
  ],
  "Metadata": {
      "color":"blue",
      "client-id":"12345"
   },
  "MessageStream": "outbound"
}




Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11263
    • View Profile
Re: Sending mail using Postmark API
« Reply #1 on: December 20, 2024, 06:24:23 PM »
cid: is just a prefix to source names in the HTML which mean "find this in the attachment list".
so, for example;
<img src="c:\images\a.png"> becomes
<img src="cid:a.png">
and a.png is added as an attachment.

As you note the NetEmail class has methods to do this for you. But it's not hard for you to do it yourself.

Cheers
Bruce