1

I am trying to send my file as an attachment in my AWS SES via AWS CLI. Given below is the message.json sample provided by aws documentation

{
   "Data": "From: sender@example.com\nTo: recipient@example.com\nSubject: Test email sent using the AWS CLI (contains an attachment)\nMIME-Version: 1.0\nContent-type: Multipart/Mixed; boundary=\"NextPart\"\n\n--NextPart\nContent-Type: text/plain\n\nThis is the message body.\n\n--NextPart\nContent-Type: text/plain;\nContent-Disposition: attachment; filename=\"attachment.txt\"\n\nThis is the text in the attachment.\n\n--NextPart--"
}

Where do I add path of the attachment file needed to this json Can anybody help?

Thanks in advance

Sangam Belose
  • 4,262
  • 8
  • 26
  • 48
Sri Vatsav
  • 13
  • 1
  • 5

1 Answers1

3

You need to encode the attachment file to Base64 and use it in the json body.

Example:

Content-Type: application/pdf; name="filename.extension" Content-Description: filename.extension Content-Disposition: attachment; filename="filename.ext"; Content-Transfer-Encoding: base64

\n\nbase-64-text-body\n\n--

You can use Python or node.js code to convert it automatically for you.

Sangam Belose
  • 4,262
  • 8
  • 26
  • 48
James Dean
  • 4,033
  • 1
  • 9
  • 18