Mass E-mail Users from Airtable
This app will send a bulk email blast based on user emails stored in an airtable base.
It's a quick and easy way to get in touch with people without the need for a more complicated emailing platform!
Setup Instructions
Step 1: Copy the email base (if you don't already have one)
You can use any airtable base, but if you're starting from scratch, I would recommend
copying this Airtable base.
Step 2: Install and Fork App
There is no external trigger for this app, so you're going to want to fork this app. Forking will create a
sandbox for this app. Once forked open up __main__.js
. This is what will facilitate the email blast.
In the bottom right you should see a big red button that says "2 Accounts Required".
Click that button to bring up the account linking modal. You will then want to click on the blue link buttons next
to the Airtable and Gmail rows.
Doing so will bring up a quick walkthrough for connecting this project to each of those accounts.
Once complete,this project will now have all the necessary pieces to start sending emails!
The code to run the Airtable Query and the Gmail Message sending is already set up and shouldn't
require any additional code to be written once you've successfully connected.
Step 3: Customize your Email Template
By default, this email sender uses /templates/template.html
as the email body.
This is the file you'll' want to customize before sending out your email blast.
If you want to use a different HTML file, simply upload it to the /templates
folder,
then change line 9 to the desired filename.
let templateFilename = './templates/your_filename_here.html';
This project uses ejs to render the HTML, a standard templating framework,
so anything you've retrieved from airtable is accessible within your template.
The basic syntax for including data form your Airtible rows in ejs is <%= row.fields['the name of your column']%>
.
This is a full templating language so I encourage you to check out the docs for more
advanced functionality, if you need it.
There is a boilerplate template to get you started, which looks like this:
If you're newer to creating HTML emails or need a refresher,
check out Email Coding 101.
There's also plenty of email template builders out there to help you generate the HTML.
If you'd prefer to keep it simple and go with plain text you can
replace this code block starting on line 25:
result.emailsSent = await Promise.all(result.emails.rows.map((row) => {
return lib.gmail.messages['@0.2.0'].create({
to: `${row.fields['email']}`,
subject: `π Hey ${row.fields['name'] || row.fields['email']}!`,
html: ejs.render(emailTemplate, {row:row}),
});
}));
with this:
result.emailsSent = await Promise.all(result.emails.rows.map((row) => {
return lib.gmail.messages['@0.2.0'].create({
to: `${row.fields.email}`,
subject: `π Hey ${row.fields.name || row.fields.email}!`,
text: `
Write your email body here!
`
});
}));
Step 4: Send the Email!
Once you've finished composing the email message you want to send, hit the Run Test Event
button
in the bottom right of the Autocode Editor.
Depending on how many emails you are messaging, this could take a little time.
Once it's complete you should see a verification message in the code runner with the full response from airtable and gmail.
It's important to note that the Gmail API does have a hard limit of 100 emails per day, so be aware of that.
If you exceed that amount you may run the risk of emails bouncing or Gmail suspending your sending privileges for a short while.
You're done! Time to start sending some emails! βοΈ
This is a really quick and simple way to send out an email blast to contacts stored in Airtable.
If you have any questions or feedback, please join our community Slack channel from the Community tab in the top bar.
You can also follow us on Twitter, @AutocodeHQ.