This repository contains a Google Apps Script that retrieves emails from your Gmail inbox and sends them to a Discord webhook in chunks. It is designed to run as a periodic task using Google's time-based triggers.
- Known Issues Spams One Message repeatedly
- Open the Google Apps Script editor for your Gmail account.
- Create a new script file and copy-paste the code from Script into it.
- Customize the
webhookUrlvariable with your Discord webhook URL. - Save the script file.
- Run the
createTriggerfunction once to set up the time-based trigger for thesendEmailsToWebhookfunction. - The
sendEmailsToWebhookfunction will be triggered every minute (you can adjust this frequency by modifying the.everyMinutes()parameter). - The script will retrieve emails from your Gmail inbox, split the content into chunks, and send each chunk to the Discord webhook.
The code consists of several functions:
sendEmailsToWebhook(): This is the main function that retrieves emails from the Gmail inbox, splits the content into chunks, and sends them to the Discord webhook.getEmailContent(message): This function extracts the subject, sender, and body of an email and returns them as a formatted string.splitIntoChunks(content, maxLength): This function splits a string into chunks of a specified maximum length.sendToWebhook(webhookUrl, message): This function sends a message to the Discord webhook using a POST request.createTrigger(): This function sets up a time-based trigger to run thesendEmailsToWebhookfunction periodically.
Feel free to modify the code to fit your specific requirements and customize the functionality according to your needs.
Contributions to this project are welcome! If you find any issues or have suggestions for improvements, please feel free to open an issue or submit a pull request.
This project is licensed under the MIT License.