Send emails with SendGrid

#1

Do you want to send emails programmatically out of a spreadsheet? You can do that with dashdash.

For this example, we use SendGrid, which provides an allowance of 100 free emails/day. You first need a SendGrid account that you get here - just click “Try for free”. Once you are in your account, you can go to Settings > API Keys > Create API Key. Then use the key to activate the SendGrid integration in your dashdash account.

Now let’s create a simple app to send emails in dashdash!

1- Store the basic parts of your request in cells

A1: Control
B1: 0

This is simply a control cell that you’ll set to 1 to send emails later, and that you can keep set to 0 while you want to avoid accidental send outs.

2- Customize email
The email has several parts to be customized. See below:

A3: Sender
A4: john.doe@example.com
B3: Recipient
B4: sam.smith@example.com
C3: Subject
C4: Hello, world!
D3: Body
D4: This is not a test.

3- Send the request
Finally, it’s time to send the request!

E3: Request
E4: =IF($B$1=1,SEND_EMAIL_SENDGRID(A4,B4,C4,D4))

That’s it! Note that this formula will still return FALSE, as our control cell to 0. Switch it to 1, and you’ll send your first email with dashdash. Set if to 0 again before you make modifications to avoid unintended send-outs.

You also might want to read about how to properly set up your SendGrid account here, e.g. to authenticate your domain to get rid of the “via sendgrid.net” on the emails you send.


If you don’t want to use our integration for some reason, you can use our POST formula to interact with SendGrid’s API like this, assuming you store your API key in cell B2:

E4: =IF(B1=1,POST("https://api.sendgrid.com/v3/mail/send" , '{"Authorization":"Bearer '&$B$2&'"}','{ "personalizations": [{"to": [{"email": "'&B4&'","name": "Sam Smith"}],"subject": "'&C4&'"}],"from": {"email": "'&A4&'","name": "John Doe"},"reply_to": {"email": "'&A4&'","name": "John Doe"},"subject": "C4","content": [{"type": "text/html","value": "<html><p>'&D4&'</p></html>"}]}'))

2 Likes
Stripe API - Authentication
Translate with Google Translate API
Building a basic technical trading tool
Track page speed with Google PageSpeed Insights API
Integrate order information from your Shopify account
Send notifications with Slack