Page 1 of 1

Adding a PDF attachment to Sendgrid Email Service

Posted: Tue May 06, 2014 6:39 pm
by Bryan Novak

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?


Adding a PDF attachment to Sendgrid Email Service

Posted: Tue May 06, 2014 7:51 pm
by Kateryna Grynko

Hi Bryan,

This should be helpful:
https://getsatisfaction.com/apperyio/...


Adding a PDF attachment to Sendgrid Email Service

Posted: Thu May 08, 2014 4:46 am
by Bryan Novak

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


Adding a PDF attachment to Sendgrid Email Service

Posted: Fri May 09, 2014 6:27 pm
by Kateryna Grynko

Hi Bryan,

You should be able to map PDF as binary data to a service parameter: http://docs.appery.io/documentation/r...

These links may also help:
http://docs.phonegap.com/en/2.5.0/cor...
https://groups.google.com/forum/#!top...
http://docs.appery.io/documentation/b...