Bryan Novak
Posts: 0
Joined: Thu May 01, 2014 4:29 pm

Adding a PDF attachment to Sendgrid Email Service

Hi there,

I have some code set up to generate a PDF file of some data generated for our users and we want them to be able to email it out. I have the email service working and the PDF generation working, but I'm having trouble attaching the PDF to the email. The email is sent using the Sendgrid API service plugin so all the data it's getting is passed to it with the following format.

{
'PATH': ['text'],
'TYPE': 'STRING',
'ID': 'Message',
'ATTR': 'value'
}, {
'PATH': ['from'],
'TYPE': 'STRING',
'ID': 'From',
'ATTR': 'value'
}, {
'PATH': ['files'],
'TYPE': 'OBJECT',
'ATTR': '[test.pdf]=@test.pdf'

Code: Select all

     } 

I've really haven't had much luck tracking down documentation on how to add attachments with the plugin for Appery. Does anyone know how the code has to be set up for the service to add attachments? Is there a way I can point it to the PDF file sitting at the root directory of the device?

Bryan Novak
Posts: 0
Joined: Thu May 01, 2014 4:29 pm

Adding a PDF attachment to Sendgrid Email Service

Thanks Katya

I've looked through the links there and I can't get any of it to work. I've found that if I format 'PATH': ['files[test.pdf]'] it will pass along a pdf as an attachment, but there's no data in it. I found a way to convert the pdf itself into binary data, but I can't figure out how to pass it into the attachment. I've been trying to make it in a variety of ways (where 'pdfPath' is a js variable holding the binary readout of the pdf file)

{
'PATH': ['files[test.pdf]'],
'TYPE': 'OBJECT',
'ATTR': '[{content : pdfPath}]'
}

I can get whatever I need from the PDF file (fullpath location, name), but I have no idea how to pass it to the service call. How does that need to be formatted? What kind of data does it actually accept?

Thanks

Return to “Issues”