This article provides a guideline on how to send an email with an inline image. This method is useful when users want to include images within the body of the email rather than as attachments. Please follow the steps below:
- Generate a Content ID: This can be any string of your choice. It will be used to reference the image within the email body.
- Reference the Content ID in the Body: Include the
content_id
in thesrc
attribute of the<img>
tag within the email body (i.e<img src="cid:<content_id>">
). - Attach the Image with the Content ID: The image should be attached to the email with the same
content_id
in theattachments
field. - Send the email: Prepare the content of the email and send them using POST/v3/grants/{grant_id}/messages/send
Below is an example of how to format the email to include an inline image.
{
"subject": "Test with Inline Image ",
"body": "<html><body>Test body <img src="cid:test-id" /></body></html>",
"to": [
{
"name": "Nylas Test",
"email": "nylas-test@gmail.com"
}
],
"attachments": [
{
"content_type": "image/png",
"filename": "Test.png",
"content": "attachment content here base64",
"content_id": "test-id"
}
]
}
Resources
Updated
Comments
0 comments
Please sign in to leave a comment.