If you have to communicate with customers or send out emails in bulk, it’s important to have a way of tracking them. And if you’re using Gmail for this purpose, then you probably know that it can be difficult to track individual emails. However, there is a way around this by using Google Sheets and Apps Scripts! Here’s how:
Open the Google Sheets application.
- Open the Google Sheets application.
- Click on the menu button in the upper left hand corner and then click Add-ons.
- Select Gmail and import modules, then click Import when prompted to do so by Google Sheets to download all add-ons related to Gmail into your account (this may take a few minutes).
4 Once installed, select “Script Editor” from under Tools with Script module for Gmail API selected, then click OK
Click on the menu button in the upper left hand corner and then click Add-ons.
To get started, click on the menu button in the upper left hand corner and then click Add-ons. Select Gmail and import modules and wait for the add-on to load.
Once you’ve imported your scripts, create a new script called Get email URLs by following these steps:
- Select Apps Script from Drive or Docs (or wherever you want this script saved).
- Click Blank Project at top left of window, then give it a name like “Get Email URLs” or whatever suits your needs best!
Select Gmail and import modules.
- Open the Google Apps Script editor.
- Select Gmail and import modules.
- Import script module for Gmail API, then wait for it to load.
Import script module for Gmail API and wait for it to load.
- Import the Gmail API.
- Wait for it to load.
- Click on the “+” next to Contacts and select Get contacts.
- Select an address, open it, and copy the email address line from there (it will look something like “john@example.com”).
Click on the “+” next to Contacts and select GET contacts.
- Click on the “+” next to Contacts and select GET contacts.
- Select an address, open it and copy the email address line.
Select an address, open it and copy the email address line.
- Open the email that you want to get a permanent URL for.
- Copy the email address line (the part before “@”).
- Paste this into the script editor and click Run:
var gmail = GmailApp; var message = gmail.getMessages(); for (i = 0; i < message.length; i++) { var subject = message[i].subject; var senderEmailAddress = message[i].from_email;
Paste this address into Gmail Scripts as in this example below.
You can then paste the email address into the box and click on Run. The script will run, and you should see results displayed in a new spreadsheet of your Google Drive account.
Now that you know how to get the permanent URL of an email message in Gmail, you can use this trick to send yourself reminders and notifications whenever you need them. For example, if you have a long list of things to do at work or home then this will be helpful for keeping track of everything without losing track along the way–and who knows what else could come from using Apps Scripts?
Sure! Here’s a step-by-step guide on how to get the permanent URL of an email message in Gmail with Apps Script:
Step 1: Open Gmail and enable Apps Script
- Open your Gmail account in a web browser.
- Click on the gear icon in the top right corner and select “Settings” from the dropdown menu.
- Go to the “Advanced” tab and enable the “Google Apps Script” option.
- Click on “Save Changes” to apply the settings.
Step 2: Access the Apps Script editor
- In your Gmail account, click on the grid icon in the top right corner of the screen to access the Google Apps menu.
- Click on “More” and select “Google Apps Script” to open the Apps Script editor.
Step 3: Create a new Apps Script project
- In the Apps Script editor, click on “New Project” to create a new project.
- Enter a name for your project and click on “Create”.
Step 4: Write the code to retrieve the permanent URL
- In the Apps Script editor, you’ll see a blank script file. Delete any existing code.
- Copy and paste the following code into the script file:
function getPermanentUrl() { var thread = GmailApp.getInboxThreads(0,1)[0]; // Get the most recent thread var message = thread.getMessages()[0]; // Get the most recent message var url = message.getPermalink(); Logger.log("Permanent URL: " + url);}
Step 5: Save and run the script
- Click on the floppy disk icon to save your script.
- To run the script, click on the Play button (►) or select “Run” from the “Run” menu.
- If prompted, authorize the script by following the on-screen instructions.
Step 6: View the permanent URL
- After running the script, go to the View menu in the Apps Script editor and click on “Logs”.
- The permanent URL of the most recent email message will be displayed in the logs.
- You can also access the URL by checking the execution transcript at the bottom of the editor.
Step 7: Modify the script (optional)
- If you want to retrieve the permanent URL of a specific email message or a different thread, you can modify the code accordingly.
- For example, to retrieve the URL of a specific message, you can use the
messageId
instead of retrieving the most recent message.
That’s it! You have successfully obtained the permanent URL of an email message in Gmail using Apps Script.
FAQ
- Q: What is a permanent URL in Gmail?
- A: A permanent URL, also known as a permalink, is a unique web address that points to a specific email message in Gmail. It allows you to access the message directly, without having to search for it in your inbox.
- Q: What is Apps Script?
- A: Apps Script is a scripting platform developed by Google that enables users to automate tasks in Google Apps. It uses a JavaScript-based language to interact with and extend various Google Apps APIs.
- Q: Is it difficult to get the permanent URL of an email message in Gmail using Apps Script?
- A: While it may seem intimidating at first, getting the permanent URL of an email message in Gmail with Apps Script is relatively straightforward. By following a few simple steps, you can obtain the URL in a matter of minutes.
- Q: Do I need to know how to code to use Apps Script?
- A: Basic coding skills are helpful but not necessary to use Apps Script. However, a familiarity with JavaScript or other programming languages can be advantageous in creating more complex scripts.
- Q: What is the benefit of using Apps Script to get email message URLs?
- A: Apps Script can help you automate tasks in Gmail and extract information more efficiently. By using a script to get the permanent URL of an email message, you can save time and streamline your workflow.
- Q: Can I use Apps Script to get the URL of any email message in my Gmail account?
- A: Yes, Apps Script can be used to retrieve the URL of any email message in your Gmail account, as long as you have permission to access the message.
- Q: Is it possible to modify the Apps Script to retrieve additional information about the email message?
- A: Yes, you can modify the script to retrieve additional information about the email message, such as the message subject, sender, recipient, and date. However, this may require more advanced coding skills.
- Q: Are there any limitations or restrictions to using Apps Script in Gmail?
- A: Yes, there are some limitations and restrictions to using Apps Script in Gmail. For example, Apps Script may not work properly in environments with limited internet connectivity, or with certain add-ons and extensions.
- Q: Can I access the Apps Script editor from my mobile device?
- A: Yes, you can access the Apps Script editor from your mobile device by using the Google Drive app. However, the editor may not be optimized for mobile devices, and coding on a small screen can be challenging.
- Q: Is it possible to integrate Apps Script with other Google Apps, such as Google Sheets or Google Docs?
- A: Yes, Apps Script can be used to interact with and automate tasks in various Google Apps, including Google Sheets, Google Docs, Google Forms, and Google Slides. By creating custom scripts, you can extend the functionality of these apps and build more powerful workflows.