Take the 2-minute tour ×
Web Applications Stack Exchange is a question and answer site for power users of web applications. It's 100% free, no registration required.

How can I export a list containing e-mail addresses for everyone that has sent me an e-mail? I have all of the messages archived.

share|improve this question
add comment

9 Answers 9

up vote 5 down vote accepted

I did quite a bit of searching for an app that works at label level and found Gmail Email Exporter from Star Banana.

It's a paid app (I have nothing to do with them) but it's cheap and you get to export email addresses from specific labels or all your Gmail account.

So in your case put all your email received into a label using a filter and use the above to export to a CSV file.

share|improve this answer
    
A cheaper alternative for Mac users is Email Contacts Extractor (itunes.apple.com/us/app/email-contacts-extractor/…). Full-disclosure: I developed it myself because I felt other offerings were too expensive or required online access to my email. –  hpique Jul 11 '13 at 9:37
    
It would be awesome if you could do a version for 20 addresses or fewer, like they do. –  Yar Sep 17 '13 at 22:40
    
starbanana.com now extracts emails out of the body too, I just tried it and the multi-threading also (does 15 labels at the same time) incredibly fast well impressed. –  Tino Mclaren Nov 9 '13 at 16:41
add comment

This is where the power of Google Apps Script kicks in. If you paste the following script in a new Google Spreadsheet (Tools, Script editor, press the bug icon to authenticate the script), then new sheets will be automatically created based on the number of labels present. After that, the e-mail addresses will be added.

function getEmails() {
  // set spreadsheet and retrieve labels
  var ss = SpreadsheetApp.getActiveSpreadsheet();  
  var labels = GmailApp.getUserLabels(), emptyLabels = [];

  // itterate through the labels
  for (var i=0; i<labels.length; i++) {

    try {
      // create sheets and clear content
      var sh = ss.getSheetByName(labels[i].getName()) || 
      ss.insertSheet(labels[i].getName(), ss.getSheets().length);
      sh.clear();

      // get all messages
      var eMails = GmailApp.getMessagesForThreads(
        GmailApp.search("label:" + labels[i].getName()))
          .reduce(function(a, b) {return a.concat(b);})
          .map(function(eMails) {
        return eMails.getFrom() 
      });

      // sort and filter for unique entries  
      var aEmails = eMails.sort().filter(function(el,j,a)
        {if(j==a.indexOf(el))return 1;return 0});  

      // create 2D-array
      var aUnique = new Array();  
      for(var k in aEmails) {
        aUnique.push([aEmails[k]]);
      }

      // add data to corresponding sheet
      sh.getRange(1, 1, aUnique.length, 1).setValues(aUnique);
    } catch (e) {
      emptyLabels.push(labels[i].getName());
    }
   }
   ss.toast("These sheets are empty: " + emptyLabels);
}

Use the SPLIT function to extract names to find duplicates. System folders are ignored, like INBOX or All Items.

Note: script might take some time to execute, which is of course dependent upon the amount of e-mails

share|improve this answer
    
I'm getting the following error when running this: TypeError: Reduce of empty array with no initial value. (line 15, file "Code") –  MG1 May 24 '13 at 1:42
    
@MG1 You might have empty labels. I will check it out –  Jacob Jan Tuinstra May 24 '13 at 7:10
    
@MG1 checked the script and it fails on empty labels. Revised code so that a message will appear, mentioning the empty labels. –  Jacob Jan Tuinstra Jun 4 '13 at 20:54
1  
The script is awesome! does what it is supposed to do. The sheets are empty toast had me confused, but a refresh of the spreadsheet got me the data I was looking for! Thanks @JacobJanTuinstra –  Moiz Tankiwala Feb 3 at 18:48
1  
This is perfect, and EXACTLY what I needed Thanks @JacobJanTuinstra. –  mrdenny Feb 21 at 3:06
add comment

The only way to do this is

  1. Export all as .txt (see: Export Gmail messages to text or HTML files)
  2. Loop through all of it and grep "From: " lines in a seperate database.

Note: if you use imapsize (free) for step 1 then save the backups as "%FROM - The sender of the email" and you have them in plain sight in your directory.

share|improve this answer
    
I was afraid of that. Thanks though! –  Brad Dec 2 '10 at 4:00
add comment

The following app is free and works beautifully!

http://www.labnol.org/internet/extract-gmail-addresses/28037/

share|improve this answer
    
Another great utility. But I am yet to try it. –  Moiz Tankiwala Feb 3 at 18:49
add comment
  1. Navigate to the list. Choose the checkbox option dropdown, and select all.
  2. [At the top you will get a hyperlink option to choose all conversations in your list. Click it.] Update: This step doesn't work, it will only let you do 25 at a time, bummer!
  3. Then go under the More dropdown and choose filter messages like these.
  4. In the filter dialogue the From textbox will be highlighted. These are all the from addresses.
  5. Copy it.
  6. Paste it in to an HTML editor like Notepad++ or Visual Studio.
  7. Now you just need to do a search and replace of the word OR, replace with ; or , .
  8. Recopy the list and paste into your message.
share|improve this answer
    
Better to just give the answer. No need for the story behind it. :-) –  Yosi Mor Aug 16 '13 at 0:07
add comment

I figured out a way to do this for Mac users using Mac Mail and address book without needing to download extra software. This works with Mac Mail 4.6 and Address Book 5.0.3. Not sure if it works for other vers or not. This may work similarly for other IMAP Email programs like Thunderbird, but I can't vouch for that.

Here are the steps:

  1. Set up your Gmail account in Mac Mail. Make sure the incoming mail server is "imap.gmail.com" You can find this under the toolbar>Mail>Preferences>Accounts.
  2. In Gmail, create a Label for the emails for which you want to extract email addresses.
  3. In Gmail, label all the emails you want per Label above.
  4. In Gmail, go to Settings>Labels and tick off the the box for the new Label you created that says "Show in IMAP."
  5. Restart Mac Mail so the new Gmail Label syncs.
  6. Open Address Book. If you use Address Book for your contacts you'll need to back up your contacts because you need to delete all contacts in Address Book. I believe you can do this with File>Export>Address Book Archive. I don't use Address Book other than for exporting Gmail emails so I can't give good advice on this. Delete Address Book contacts at your own risk.
  7. In Address Book, delete all your contacts. You should be able to do this by selecting one contact, pressing Command+a and pressing the delete key.
  8. In Mac Mail, find your IMAP folder. There should be a column on the left side of the window with all your Mailboxes. If not go to the top toolbar, select View>Show Mailboxes or press Command+Shift+M. The IMAP folder will be toward the bottom of the column below "Reminders", "RSS", "On My Mac" etc. You should see the Name of your Gmail account you set up earlier with a dropdown arrow on the left.
  9. In Mac Mail, click the dropdown arrow next to your mailbox. This will show you a list of folders and should show the Label you created in Gmail as a folder. Select this folder by clicking it.
  10. In Mac Mail in the Messages window )which should now display all your emails for you Gmail Label), select all the emails in the list. Go to the top toolbar, select Messages>Add Senders to Address Book or press Shift+Command+Y. All the senders for your Gmail Label should now be in Address Book.
  11. In Address Book you can now export contacts as vCards to use in whatever program you like by going to the toolbar and selecting File>Export>Export vCards. You can even import back into Google Contacts. If you need a CSV file, unfortunately you will need to import the vCards into another program (Google Contacts works) and re-export because you cannot export CSV from Mac Mail.

Hope this helps! It's a bit cumbersome, but works for me and is pretty easy after you do it a couple of times.

share|improve this answer
add comment

Based off of @jacob-jan-tuinstra's answer. Made some minor modifications to suit my needs perhaps others would find it useful.

Uses search, doesn't break up by labels and also does chunking for large inboxes.

The part that says 'YOUR GMAIL SEARCH QUERY GOES HERE' can be filled with any query you would use in your inbox.

function getEmails() {
  // set spreadsheet and retrieve labels
  var query = 'YOUR GMAIL SEARCH QUERY GOES HERE',
    ss = SpreadsheetApp.getActiveSpreadsheet(),
    sh = ss.getSheetByName(query) || ss.insertSheet(query, ss.getSheets().length),
    uniqueEmails = {},
    errors = [],
    // max chunk size
    chunkSize = 500,
    currentChunk = 0,
    threads,
    messages,
    i,
    j,
    k,
    msg,
    tos;
  sh.clear();
  while (currentChunk === 0 || threads.length === chunkSize) {
    try {
      // grab threads that match the query one chunk at a time
      threads = GmailApp.search(query, chunkSize * currentChunk, chunkSize);
      // grab corresponding messages from the threads
      messages = GmailApp.getMessagesForThreads(threads);
      for (i = 0; i < messages.length; i++) {
        msg = messages[i];
        for (j = 0; j < msg.length; j++) {
          // get the from
          uniqueEmails[msg[j].getFrom()] = true;
          // get the reply to
          uniqueEmails[msg[j].getReplyTo()] = true;
          // grab from the to field as well
          // this has a bug for people with commas in their names
          // tos = msg[j].getTo().split(',');
          // for (k = 0; k < tos.length; k++) {
          //  uniqueEmails[tos[k]] = true;
          // }
        }
      }
      currentChunk += 1;
    } catch (e) {
      errors.push(e);
    }
  }
  // create 2D-array
  var aUnique = [];
  for (k in uniqueEmails) {
    aUnique.push([k]);
  }

  // add data to corresponding sheet
  sh.getRange(1, 1, aUnique.length, 1).setValues(aUnique);
}
share|improve this answer
    
your scrpit works perfectly for me, thanks! can you add the option to retrieve email addresses from the body of the email as well, much appreciated. thanks. –  user74582 Jul 16 at 6:19
add comment

MineMyMail fetches all of your messages via IMAP and then extracts the email addresses from it.

You can choose which folders it searches by selecting the "Sent Mail" folder/label.

share|improve this answer
4  
Could you describe in a bit more detail. –  phwd Mar 1 '13 at 19:10
    
MineMyMail fetches all of your messages via IMAP and then extracts the email addresses from it. You can choose which folders it searches by selecting the "Sent Mail" folder/label. –  Jason Vallery Mar 12 '13 at 19:04
    
Is MineMyMail trustworthy? I went to their site and Chrome warned me that the certificate has expired. Not having a proper HTTPS certificate and asking users to enter their Gmail username and password is definitely scary. It leads me to suspect that the site might extract the emails and use it for their own spamming or selling to other spammers. –  Moiz Tankiwala Feb 3 at 18:52
add comment

IMAP Addresses Exporter is a Mac App that connects to any IMAP email account and extracts every sender address, also from folders/label you set previously. In all fairness I have to highlight that it is developed by my company.

share|improve this answer
add comment

protected by Community Jul 16 at 7:52

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.