Google Apps Script to listen for emails, extract URLs, convert web pages to PDFs, and reply with the screenshots as PDF attachments.
This project uses Google Apps Script to automatically process incoming emails sent to a specific alias (e.g., mygmail+screenshot@gmail.com). It performs the following tasks:
- Searches for unread emails sent to the alias.
- Extracts URLs from the email's subject and body.
- Converts the web pages into PDF files.
- Replies to the original email with the PDF screenshots as attachments.
-
Create a Google Apps Script Project:
- Go to Google Apps Script.
- Click on
New Project.
-
Copy and Paste the Script:
- Replace any existing code with the script provided below.
- Make sure to replace
"your-email@example.com"with your actual email address.
-
Deploy the Script as a Web App:
- Click on
Deploy->New deployment. - Select
Web app. - Configure the deployment:
- Give it a description.
- Set
Execute astoMe. - Set
Who has accesstoAnyone.
- Click
Deploy.
- Click on
-
Set Up Triggers:
- Go to
Edit->Current project's triggers. - Add a new trigger:
- Choose
processEmailsfunction to run. - Select
Time-driven->Minutes timer->Every 5 minutes(or any suitable frequency).
- Choose
- Go to