Created
June 27, 2021 07:31
-
-
Save theindianappguy/1ae32a0c5f3a4361161ebc6cad5d5ac5 to your computer and use it in GitHub Desktop.
Get Email Id By Subject
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function onOpen() { | |
var Ui = SpreadsheetApp.getUi() | |
var menu = Ui.createAddonMenu() | |
.addItem("Get Message ID", "getMsgIds") | |
.addToUi() | |
} | |
function getMsgIds() { | |
var MsgSubject = Browser.inputBox("Enter the subject of the Email"); | |
if (!MsgSubject) { | |
Browser.msgBox("oh oh, seems you forgot to provide the message subject, please try again. I\n\\n\\n\\n Thank you! \\n\\n Regards, l\n G") | |
} | |
if (MsgSubject) { | |
var Threads = GmailApp.search('subject:' + '"' + MsgSubject + '"') | |
for (i = 0; i < Threads.length; i++) { | |
var MsgId = Threads[i].getId() | |
var Subject = Threads[i].getFirstMessageSubject() | |
Logger.log(`Subject: ${Subject}, MsgId: ${MsgId}`); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment