๐Ÿ”Œ
MailVault is disconnected
Gmail access was removed โ€” reconnect to restore full access.
๐Ÿ”Œ
Connection Lost

Reconnect to MailVault

MailVault lost access to your Gmail because permissions were removed from your Google account. Visit myaccount.google.com/permissions if this was accidental.

1
Click Reconnect below โ€” you will be taken back to the app URL.
2
Google will show the authorization dialog again automatically.
3
Click Allow to restore Gmail access โ€” then use the app normally.
Complete Guide & Source Code

MailVault

A free Gmail exporter that runs entirely inside your Google Account. No cloud setup, no subscriptions, no data leaving Google's servers.

๐Ÿ”’ Zero Cloud Setup
๐Ÿ“ Saves to Your Device
โšก 5-Minute Install
๐Ÿ‘๏ธ Open Source
On This Page
How It Works

MailVault is a Google Apps Script project that lives inside your own Google Account. It reads your Gmail on request, lets you review and manage the results, then downloads the export directly to your device.

๐Ÿ 
Stays in Google
Runs on Google's servers inside your account. Never touches outside infrastructure.
๐Ÿ“–
Read-Only Gmail
Can only read emails. Cannot send, delete, or modify anything.
๐Ÿ’พ
Local Downloads
CSV, PDF, and Text files download directly to your device โ€” not to Drive.
โœ๏ธ
Edit Before Export
View, edit, or remove emails from the list before downloading.
๐Ÿ”€
Sort & Filter
Sort by newest, oldest, subject, or sender before exporting.
๐Ÿ‘๏ธ
Open Source
Full source code below โ€” every line is readable and auditable.
๐Ÿ”’
Your data never leaves Google
The script runs server-side inside your Google Account. Emails flow from Gmail โ†’ your browser โ†’ your local device. No third-party servers, no analytics, no data collection of any kind.
⚠️
First-time users must complete Authorization
The first time anyone opens the app URL, Google will show an "Authorization needed" dialog. Users must complete all authorization steps to grant Gmail access. See the Authorization Guide section below for the exact steps.
🔗 Live App URL — Share This
https://script.google.com/macros/s/AKfycbxbfKNTOwqhcnOjz6r3J7Tgy8x1Gjh-fIvb8DxMzPGL4xC0VTX8dp1hyot0hupCD72J/exec
Live on Google Apps Script
Read all sections below — especially the Authorization Guide — before opening this link.
Authorization Guide

The first time you open the app, Google will ask you to authorize MailVault. You must complete all four steps below โ€” this only happens once.

🔐
Why authorization is required

MailVault is a Google Apps Script. Before it can read your Gmail, Google requires you to explicitly grant permission. The script runs entirely inside your own Google account — you are authorizing your own script, not a third-party company.

1
Open the App URL — Click "Review Permissions"

Open the app link above in your browser. A Google popup will appear titled "MailVault (Unverified)" saying:

Google Apps Script
MailVault (Unverified)
MailVault needs your permission to access your data on Google.
When reviewing permissions, consider whether you trust MailVault.
CANCEL
REVIEW PERMISSIONS

Click the blue REVIEW PERMISSIONS button to continue.

2
Choose Your Google Account

Google will show a list of signed-in accounts. Select the Google account whose Gmail you want to export from. Make sure it matches the email the app owner added to the access list.

💡
Not seeing your account?
Click "Use another account" on the account picker screen and sign in with the correct Gmail address.
3
Bypass the "Unverified App" Warning

Google shows a safety screen: "Google hasn't verified this app". This is expected — MailVault is a personal script and has not gone through Google's commercial app review process.

⚠️  Google hasn't verified this app
The app is requesting access to sensitive info in your Google Account. Until the developer (MailVault) verifies this app with Google, you shouldn't use it unless you trust the developer.
Back to safety
Advanced
3a Click Advanced (small link, bottom-left of the warning screen)
3b A new link appears: click "Go to MailVault (unsafe)" to proceed past the warning
🔑
Is this safe?
Yes. "Unsafe" refers to the fact that the script hasn't been commercially verified by Google — not that it contains malware. The full source code is visible in this page's Source Code section so you can audit every line before proceeding.
4
Click Allow — Grant Full Gmail Read Access

The final screen lists every permission MailVault needs. You must click Allow to grant all of them. Without this, the app cannot function.

📧
Read, compose, send, and permanently delete all your email from Gmail
MailVault only reads email. It never composes, sends, or deletes — Google's permission dialog uses a broad label for the read scope.
👤
See your personal info including any personal info you've made publicly available
Used to display your name and profile photo in the app's nav bar only.
Connect to an external service
Standard Apps Script permission. MailVault makes no external connections.
Click Allow on that screen to complete authorization Allow
Authorization complete — one time only
After clicking Allow, the app loads immediately. This 4-step process only happens once per Google account. Every future visit goes straight to the app.
One-Time Setup

Takes about 5 minutes. After setup, just open your Web App URL anytime to export emails.

Step
01
Go to Google Apps Script

Open script.google.com and sign in with the Gmail account you want to export from.

Step
02
Create a New Project

Click + New project โ†’ rename it to MailVault.

Step
03
Paste Code.gs

The editor opens with Code.gs by default. Select all โ†’ delete โ†’ paste the Code.gs source below โ†’ Ctrl+S.

Edit the ALLOWED_EMAILS array with the email addresses you want to allow access.

Step
04
Add the index.html File

Hover over "Files" in the left sidebar โ†’ click + โ†’ choose HTML โ†’ name it index (no .html extension).

Delete the placeholder โ†’ paste the index.html source below โ†’ Ctrl+S.

Step
05
Deploy as a Web App

Click Deploy โ†’ New deployment โ†’ โš™๏ธ gear โ†’ Web app.

Set: Execute as: Me ยท Who has access: Anyone with Google account

Click Deploy โ†’ Authorize โ†’ Allow.

โœ“ Copy the Web App URL โ€” bookmark it!

Step
06
Share Securely

Share the Web App URL with anyone you added to ALLOWED_EMAILS.

Anyone NOT on the list will see a styled Access Denied page โ€” no data is exposed.

โœ“ Done! Open the URL to start exporting.

๐Ÿ’ก
Updating the app
After editing Code.gs or index.html, go to Deploy โ†’ Manage deployments โ†’ โœ๏ธ pencil โ†’ Version: New version โ†’ Deploy. Your URL stays the same.
App Features

Open your Web App URL. You'll see a welcome screen with your Google profile, then the app has three steps.

Welcome Screen

When you open the URL, a login/welcome screen appears showing your Google profile photo, name, and email address. Click Enter MailVault to proceed. Users not on the allowed list see a styled Access Denied page instead.

Step 01 โ€” Date Range

Set a From and To date. Your Gmail address is automatically detected and shown. For a single day, set both dates to the same date.

Step 02 โ€” Fetch & Manage

Click Fetch Emails to search Gmail. Results appear in a table with four actions per email:

๐Ÿ‘ View

Opens a modal with all email fields: Subject, From, To, CC, Date, Labels, Body, Read/Starred status.

โœ๏ธ Edit

Opens an editable form. Edits only affect the export โ€” Gmail is untouched.

๐Ÿ—‘ Remove

Removes from the export list. Does not delete from Gmail.

๐Ÿ”€ Sort

Sort by Newest, Oldest, Subject Aโ€“Z, or From Aโ€“Z using buttons above the table.

Step 03 โ€” Export to Device

Choose a format and click Download. Files save directly to your device's Downloads folder:

๐Ÿ“Š
CSV
Opens in Excel or Google Sheets.
๐Ÿ“•
PDF
Print-ready. Choose Save as PDF in the print dialog.
๐Ÿ“„
Text
Plain .txt file with ASCII borders.
Remove MailVault from Your Account

Follow all three steps to completely remove MailVault. Each step removes a different component.

A
Revoke Gmail Permissions

This stops the script from accessing your Gmail.

myaccount.google.com/permissions

1. Go to the URL above and sign in.
2. Find MailVault in the list.
3. Click it โ†’ click Remove Access โ†’ confirm.

B
Delete the Apps Script Project

This deletes the script code and permanently invalidates the Web App URL.

script.google.com

1. Find your MailVault project.
2. Click the โ‹ฎ menu โ†’ Remove โ†’ confirm.

C
Delete Exported Files (Optional)

Any CSV, PDF, or TXT files you downloaded live on your own device. Delete them from your Downloads folder manually if needed.

โœ…
Full Removal Checklist
โœ“ Revoked permissions at myaccount.google.com/permissions
โœ“ Deleted the project at script.google.com
โœ“ Deleted any exported files from your device

After all three steps, MailVault has zero presence in your Google account.
Troubleshooting

"Script function not found: doGet"

Code.gs was deployed before being saved. Re-paste Code.gs, press Ctrl+S, then create a new deployment version.

"No emails found" for a date you know has emails

Widen the date range by one day in each direction. Gmail's date search can be offset by your timezone.

"Script timeout" error

Google Apps Script has a 6-minute execution limit. Use a shorter date range.

"Access Denied" page appears

Your email is not in the ALLOWED_EMAILS array in Code.gs. Add your email there and redeploy a new version.

Profile photo doesn't appear on welcome screen

The People API may not be enabled. The app falls back to showing your name initials as an avatar โ€” all other features still work normally.

Full Source Code

Both files are below. Click Copy Code on each, then paste into Apps Script.

๐Ÿ“‹
How to use these
1. Click Copy Code on the file you need.
2. Go to script.google.com โ†’ open your MailVault project.
3. Click inside the correct file (Code.gs or index.html) โ†’ Ctrl+A โ†’ Ctrl+V to paste.
4. Press Ctrl+S to save, then deploy a new version.
Code.gs โ€” Backend Script
Loadingโ€ฆ

    
index.html โ€” Frontend UI
Loadingโ€ฆ

    
Launch MailVault

You've read everything you need to know. Tick each confirmation below, then click the Launch button to open the app.

I have read the How It Works section and understand MailVault runs inside my Google account
I have read the Authorization Guide and I know how to complete the 4-step Google permission flow
I understand that clicking Allow grants MailVault read access to my Gmail and I trust this script
I have read the Troubleshooting section so I know what to do if something goes wrong
Tick all 4 checkboxes to unlock the Launch button
Open MailVault
You must tick all checkboxes before launching.