invitation india
UnexpectedWeb
Connect

Popular Technology Blog where you'll find some interesting things around the web, that you never knew existed.

link Link copied

Get all the email addresses in Gmail account with google app script

Share on: link Link copied

With the help of Google App Script, you can easily extract all the email addresses in your Gmail inbox and save it in Google Sheets. Use this script to collect all email addresses from the mail received in your Gmail inbox.

1. Create a new Google Sheet
2. Go to Tools > Script editor
3. Pase following code, Save and Run (allow permissions)


Code:

function getInboxEmailsList() { var threads = GmailApp.getInboxThreads(); var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sheet1"); var data = sheet.getDataRange().getValues(); var column = 1; var row = 1; var EmailList = []; var lastrow = sheet.getLastRow(); for (var x = 0; x < lastrow; x++) { EmailList.push(data[x][column-1]); } for (var i = lastrow; i < threads.length; i++) { var messages = threads[i].getMessages(); var senderEmail = messages[0].getFrom(); var searchResult = EmailList.indexOf(senderEmail); if(searchResult == -1){ SpreadsheetApp.getActiveSheet().getRange(row,column).setValue(senderEmail); EmailList.push(senderEmail); row++; } } }

No comments:

Powered by Blogger.