Sendgrid Attachments

Hello all!

I have an app that uses PDFGeneratorAPI to create a PDF sales order. I was wondering if there was a way to attach that sales order to an email and send with Sendgrid?



I also have another app, if this is possible, where users upload documents (pictures and PDFs mostly) to the Adalo DB and i’d like to be able to send those as attachments in Sendgrid as well if anyone has any ideas.


I think you can just include the link URL. When referencing a file from Adalo database, there is an option to use the URL. This would probably not actually ‘attach it’, just show the link in the message. To attach it, the sendgrid API probably has a method to do this whereby you give sendgrid the URL of the attachment.

1 Like

Yeah, I was hoping for an actual attachment.

Yes, this is what I was hoping to find an answer for :slight_smile:

One last bump.

Looks like you can have an attachment object like this in the json body:

"attachments": [{"content": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCiAgICA8aGVhZD4KICAgICAgICA8bWV0YSBjaGFyc2V0PSJVVEYtOCI+CiAgICAgICAgPG1ldGEgaHR0cC1lcXVpdj0iWC1VQS1Db21wYXRpYmxlIiBjb250ZW50PSJJRT1lZGdlIj4KICAgICAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCI+CiAgICAgICAgPHRpdGxlPkRvY3VtZW50PC90aXRsZT4KICAgIDwvaGVhZD4KCiAgICA8Ym9keT4KCiAgICA8L2JvZHk+Cgo8L2h0bWw+Cg==", "filename": "index.html", "type": "text/html", "disposition": "attachment"}],

I guess that long strong is Base64 format.

I got this here Mail Send | Twilio

If you see the sample box on the right hand side of box and choose CURL, you can see the full json body sample as below:

--data '{"personalizations": [{"to": [{"email": "", "name": "John Doe"}, {"email": "", "name": "Julia Doe"}], "cc": [{"email": "", "name": "Jane Doe"}], "bcc": [{"email": "", "name": "Jim Doe"}]}, {"from": {"email": "", "name": "Example Sales Team"}, "to": [{"email": "", "name": "Janice Doe"}], "bcc": [{"email": "", "name": "Jordan Doe"}]}], "from": {"email": "", "name": "Example Order Confirmation"}, "reply_to": {"email": "", "name": "Example Customer Service Team"}, "subject": "Your Example Order Confirmation", "content": [{"type": "text/html", "value": "<p>Hello from Twilio SendGrid!</p><p>Sending with the email service trusted by developers and marketers for <strong>time-savings</strong>, <strong>scalability</strong>, and <strong>delivery expertise</strong>.</p><p>%open-track%</p>"}], "attachments": [{"content": "PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9ImVuIj4KCiAgICA8aGVhZD4KICAgICAgICA8bWV0YSBjaGFyc2V0PSJVVEYtOCI+CiAgICAgICAgPG1ldGEgaHR0cC1lcXVpdj0iWC1VQS1Db21wYXRpYmxlIiBjb250ZW50PSJJRT1lZGdlIj4KICAgICAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLCBpbml0aWFsLXNjYWxlPTEuMCI+CiAgICAgICAgPHRpdGxlPkRvY3VtZW50PC90aXRsZT4KICAgIDwvaGVhZD4KCiAgICA8Ym9keT4KCiAgICA8L2JvZHk+Cgo8L2h0bWw+Cg==", "filename": "index.html", "type": "text/html", "disposition": "attachment"}], "categories": ["cake", "pie", "baking"], "send_at": 1617260400, "batch_id": "AsdFgHjklQweRTYuIopzXcVBNm0aSDfGHjklmZcVbNMqWert1znmOP2asDFjkl", "asm": {"group_id": 12345, "groups_to_display": [12345]}, "ip_pool_name": "transactional email", "mail_settings": {"bypass_list_management": {"enable": false}, "footer": {"enable": false}, "sandbox_mode": {"enable": false}}, "tracking_settings": {"click_tracking": {"enable": true, "enable_text": false}, "open_tracking": {"enable": true, "substitution_tag": "%open-track%"}, "subscription_tracking": {"enable": false}}}'

The first thing I might do here is see if just entering a URL instead of base64 works. If that doesn’t work, see if you can use an API to return base64 from the file URL.

Yeah I tried this originally with the API (Just using the URL) and it didnt work. The email wouldnt even send.

Know any API’s that return a base64?

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.