29 October 2026 · Practical AI builds
How do I file form enquiries into a spreadsheet automatically?
By the end of this you will have a spreadsheet that fills itself. Each enquiry email from your website form lands as a new row with the date, name, email, phone and message, and you never copy and paste again. It suits anyone whose form sends enquiries to a Gmail or Google Workspace inbox and who would rather keep track of leads in a sheet than in a busy inbox.
I learn my automation tips in the AI Profit Boardroom. Have a look here. Affiliate link.
What you need
- A Google account (free Gmail or Google Workspace) that receives the form emails.
- A Google Sheet to hold the enquiries.
- Google Apps Script, which comes with every Google account at no extra cost.
- A website form that sends the same layout every time, for example lines like
Name: ...andEmail: .... Most form plugins and form services do this. - About half an hour, and the confidence to paste a short script and press Run. No coding experience is needed.
Step by step
- Open one enquiry email and note exactly how the fields are labelled, for example
Name:,Email:,Phone:andMessage:. The script relies on these labels. - In Gmail, create two labels:
enquiriesandenquiries-filed. - Make a Gmail filter that matches your form emails (by the sender address or a subject such as "New enquiry") and applies the
enquirieslabel. Tick the option to apply it to matching emails you already have if you want to backfill. - Create a Google Sheet, rename the first tab to
Enquiries, and type headings in row 1: Date, Name, Email, Phone, Message, Message ID. - In the sheet, open Extensions, then Apps Script, delete the sample code and paste the script below. Change the field labels if yours differ.
- Press Run once. Google will ask you to allow the script to read your Gmail and edit the sheet. Read the request, then allow it.
- Check the sheet. Any labelled emails should now be rows, and in Gmail they should have moved from
enquiriestoenquiries-filed. - In Apps Script, open Triggers (the clock icon), add a trigger for
fileEnquiries, choose "Time-driven" and pick every 15 minutes or every hour.
function fileEnquiries() {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Enquiries');
const todo = GmailApp.getUserLabelByName('enquiries');
const done = GmailApp.getUserLabelByName('enquiries-filed');
const threads = todo.getThreads(0, 50);
threads.forEach(thread => {
thread.getMessages().forEach(msg => {
const body = msg.getPlainBody();
const field = name => {
const m = body.match(new RegExp('^' + name + ':\\s*(.*)$', 'mi'));
return m ? m[1].trim() : '';
};
sheet.appendRow([
msg.getDate(),
field('Name'),
field('Email'),
field('Phone'),
field('Message'),
msg.getId()
]);
});
thread.addLabel(done);
thread.removeLabel(todo);
});
}The script only looks at emails carrying the enquiries label, files them, then swaps the label so the same email is never filed twice. The Message ID column lets you find the original email later if you need to.
What good looks like
Send a test enquiry through your own website form. Within one trigger interval a new row should appear with every column filled in, and the email in Gmail should show the enquiries-filed label. If a column comes out blank, the label in the email does not quite match the one in the script (check spelling, capitals and the colon). If nothing happens at all, open Executions in Apps Script to see the error.
Watch out for
- Long messages. The simple pattern above only picks up the first line of each field. If people write several paragraphs, the rest of the message is not copied. Either keep the full email body in an extra column using
msg.getPlainBody(), or have your form put the message field last and capture everything after it. If your emails are messy and you are tempted to have an AI model pull the fields out, that can work, but it can also misread or invent details, so keep the original email and check anything important (see how to keep AI replies from inventing facts). - Personal data. Enquiries contain names, emails and phone numbers, so the sheet holds personal data. Share it only with people who need it, do not make the link public, and delete old rows you no longer need. Spam submissions will be filed too, so a quick human glance at new rows is still worth doing.
Questions people ask
Does this work if my enquiries go to Outlook instead of Gmail?
Not as written, because Apps Script reads Gmail. You can forward form emails to a Gmail address and use the same steps, or use an automation tool that connects to Outlook and to a spreadsheet, though those often need a paid plan for regular use.
Is there a limit on how many enquiries it can handle?
Google sets daily limits on how much a script can read from Gmail, and the limits depend on your account type, but a small business inbox is very unlikely to reach them. The script files up to 50 threads per run, and anything left over is picked up on the next run.
That is the whole build: a Gmail filter labels each enquiry, a short script copies the fields into a sheet on a timer, and a second label stops anything being filed twice.
Want more automation tips? The AI Profit Boardroom on Skool is where I get mine. Have a look here. Affiliate link.