Inline image attachments with postmark api - html-email

I'm trying to use the postmark api to send an html email that has images in it. I know postmark supports inline image attachments but i don't know how to go about it. I've gone through the documentation but the example given there seems vague and i quite understand it.
How do i go about this?

Your API call would basically look like this:
{
"From": "signature#yourdomain.com",
"To": "someone#example.com",
"Subject": "Regular API Test",
"Tag": "inline",
"HtmlBody": "<html><body><strong>hello bacon!</strong<br /><img src=\"cid:myimagecid\"/></body></html>",
"TextBody": "Hello",
"Attachments": [
{
"Name": "bacon.jpg",
"Content": "/9j/4AAQSkZJRgABAQEAZABkAAD/2wBDAAQDAwQDAwQEBAQFBQQFBwsHBwYGBw4KCggLEA4RERA...gDgBAA9GT/APrP/9k=",
"ContentType": "image/jpeg",
"ContentID": "cid:myimagecid"
}
]
}
You compose your html with references to the image by way of a ContentID (CID) instead of specifying a link to the source. Then, you embed the base64 converted string of your image as the Content part of the attachment. The ContentID field lets the html know where to find the image data in the email.
You can use the framework of whatever platform your using to encode the images as base64. To practice, try a site like http://www.base64-image.de/step-1.php which will give you the base64 string of an uploaded image.

Related

How to send activity output as email attachment in logic app

I have an ADF pipeline, I want to send the output of my activity as an email attachment in the logic app.
I have a lookup activity followed by a For each activity and an Inside For each activity I have a web activity to call the logic app.
I want to send the output of the lookup activity as an email attachment to the logic app. I am not able to think about this integration part.
Create Logic app event trigger with HTTP and Outlook.
Inside HTTP request is received:
Copy HTTP POST URL
Request Body JSON Schema
{ "properties": { "dataFactoryName": { "type": "string" }, "message": { "type": "string" }, "pipelineName": { "type": "string" }, "receiver": { "type": "string" } }, "type": "object" }
POST Method
Send an Email
Connect Your outlook email .
Use HTTP POST URL as shown in step1
Create parameter name receiver
Add dynamic this content
s
{
"message" : "This is the row from lookup item #{item().customerID},#{item().gender},#{item().SeniorCitizen},#{item().Partner}.",
"dataFactoryName" : "#{pipeline().DataFactory}",
"pipelineName" : "#{pipeline().Pipeline}",
"receiver" : "#{pipeline().parameters.receiver}"
}
Pipeline successfully executed and got the output:
There is no direct or easy way to send email attachment from ADF.
But as a workaround first you will have to save the output of your lookup activity to a file and then follow the approach described in this video by a community volunteer where logic apps come into play to send the lookup activity output data file as an attachment. How To Send File as Attachment From Azure Data Factory - Azure Data Factory Tutorial 2021
In order to save the lookup output data to a file you can follow this approach: Get Output of lookup activity in a file

Is there a way to retrieve the generated HTML email body of a dynamic template via SendGrid API call?

We have a site where our agents enter in some data, and then that data is sent to a client, via a SendGrid dynamic template.
The email content includes a lot of calculations based on the data entered, so we want our agents to have the ability to preview the email and verify the content first before sending it to the client.
Is there a way to use the SendGrid API to send a request with our json object, but instead of sending the email to the client, receive the generated email body so that we can display it to the agent and let them review it first?
Answered my own question. API v3 has GET methods for Dynamic Transactional Templates and Template Versions.
API Call:
/templates/{template_id}/versions/{version_id}
using sendgrid-ruby:
sg = SendGrid::API.new(api_key: sendgrid_api_key)
sg.client.templates._(template_id).versions._(template_version_id).get
(Note: the template_version_id is the ID and not the Name of the template version)
The response body then includes a field called html_content which is the full rendered HTML of a dynamic template version with any handlebar templating.
You can make API call via postman as:
https://api.sendgrid.com/v3/templates/d-d44fdfsdfdsfd342342343
with Bearer token along with Sendgrid API key like:
Bearer SG.Fvsdfsdjfksdfsdfjsdkjfsdfksjdfsdfksjdfkjsdkfjsdf
The response is:
{
"id": "d-d55d081558a641b48a8a1145b4549fbe",
"name": "Bt_Payment_Reminder (Active)",
"generation": "dynamic",
"updated_at": "2021-12-21 07:35:12",
"versions": [
{
"id": "a95c3652-e49f-4608-a9dd-5aa4831c2dc3",
"user_id": 11702857,
"template_id": "d-d55d081558a641b48a8a1145b4549fbe",
"active": 1,
"name": "Bt_Payment_Reminder_Updated",
"html_content": "Hello {{firstName}}",
"plain_content": "Hello {{firstName}}",
"generate_plain_content": true,
"subject": "{{subject}}",
"updated_at": "2021-12-21 07:37:48",
"editor": "code",
"test_data": "{\n \"firstName\":\"Virendra\"}",
"thumbnail_url": "sdasdasdasdasdasdsd"
}
]
}

How can I include JSON body API examples in Swagger2Markup API requirements (when converting from Swagger YAML)?

I've used the Swagger editor (editor.swagger.io) to create API requirements that look great online in a web browser, but I want to convert this Swagger YAML documentation into a format that can be printed (Word, PDF, Excel, HTML) and read offline.
The only way I've seen to convert the Swagger YAML into a clean, printable API requirements document is using the Swagger2Markup CLI (here's the reference documentation: http://swagger2markup.github.io/swagger2markup/1.3.3/ - Chapter 8 describes the CLI), then converting this adoc format to HTML from AsciiDoctor. The final product is very readable as you can see from the Swagger2Markup reference documentation.
However, unfortunately, the final Swagger2Markup documentation of an API doesn't include JSON or xml examples of the API body, which is arguably the most important part of the documentation in my opinion! For example, in the Swagger editor's petstore, this would be the json body example for the POST /pet API:
{
"id": 0,
"category": {
"id": 0,
"name": "string"
},
"name": "doggie",
"photoUrls": [
"string"
],
"tags": [
{
"id": 0,
"name": "string"
}
],
"status": "available"
}
But this JSON example isn't included in the Swagger2Markup documentation.
So my question is, is it possible to update Swagger2Markup (or change the Swagger2Markup properties) to include JSON body API examples in the final document?
If not, is there a different way you recommend converting Swagger YAML into a readable document that includes JSON body API examples?
To add json body API examples to the adoc with swagger2markup, create a config file (config.properties) and add "swagger2markup.generatedExamplesEnabled=TRUE". Per the swagger2markup reference document, section 3.2.5, this property specifies if http rquest and response examples should be generated. Awesome!

Can I attach files (PDF) to customer.io REST API?

I am trying to send an email through customer.io service and I need to attach a PDF to it. Ive seen little documentation about attachments, so I dont know if it is possible.
I am trying this approach
{
name: 'myCampaign',
data: {
foo: 'bar',
},
attachments: {
'file.pdf': pdfInB64
}
}
As the example here: https://gist.github.com/jrallison/3e43c58cb208841caf11
Thank you !!
It is possible to send PDF's as attachments via customer.io. I think one of your issues is that your attachments object needs to be nested inside of your data object. Ex.
{
"name": "foo_bar",
"data": {
"foo": "bar",
"attachments": {
"helloworld.pdf": "some base64 encoded pdf here"
}
}
}
However, one caveat here is that there's a limit to the size of attachments.
Well, apparently is not possible the way I was thinking about it. For PDF is better to have a link to a host you own
<img src="LINK TO THE DOWNLOAD PDF IMAGE" alt="Download your PDF file">

How to retrieve attachments from Facebook Graph API?

I'm struggling to find a method to retrieve attachments from a message via the Graph API.
When I request the message (m_mid.xxxxxx/attachments), I get the response:
"data": [
{
"id": "105446924xxxxxx",
"mime_type": "application/pdf",
"name": "some.pdf",
"size": 89628
}
]
Any way to get the attachment link or the file itself?
The documentation only lists four fields that you can use as query parameters to filter the results, and these are the same as the response to your request.
However, if you remove the fields parameter from the request, you'll also get an image_data object which includes URLs.
For example:
https://graph.facebook.com/v5.0/{message_id}/attachments?access_token={page_access_token}