• Visitors can check out the Forum FAQ by clicking this link. You have to register before you can post: click the REGISTER link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. View our Forum Privacy Policy.
  • Want to receive the latest contracting news and advice straight to your inbox? Sign up to the ContractorUK newsletter here. Every sign up will also be entered into a draw to WIN £100 Amazon vouchers!

You are not logged in or you do not have permission to access this page. This could be due to one of several reasons:

  • You are not logged in. If you are already registered, fill in the form below to log in, or follow the "Sign Up" link to register a new account.
  • You may not have sufficient privileges to access this page. Are you trying to edit someone else's post, access administrative features or some other privileged system?
  • If you are trying to post, the administrator may have disabled your account, or it may be awaiting activation.

Previously on "Extract all sender's email addresses from emails"

Collapse

  • xoggoth
    replied
    I used live mail on Windows at the time, emails were in Appdata\local. Don't know where Mac saves things by default but I daresay all email apps allow backup to folder of your choice. Some parts of emails are encoded but the headers are always plain text AFAIK.
    Last edited by xoggoth; 26 September 2021, 16:45.

    Leave a comment:


  • BR14
    replied
    Originally posted by xoggoth View Post

    Excel VBA does it quite easily. Used to do it to check order emails until they started putting everything into PDF.

    Code below is quick untested extract from a much more complicated thing so probably got a few errors, but close enough.

    'Option Compare Text
    Public r As Integer

    Private Sub CommandButton1_Click()
    Dim fold As String

    'clear list
    Range("A15:A500").Select
    Selection.ClearContents
    Range("A15").Select

    'sheet row
    r = 1

    'For each folder in list
    fol = 1
    Do
    fold = Range("C5").Cells(fol, 1).Value
    If fold <> "" Then
    getemails (fold)
    fol = fol + 1
    End If
    Range("AF2").Value = fol
    Loop While fold <> ""

    End Sub

    Sub getemails(mailpath As String)
    Dim FSO As FileSystemObject
    Dim fileList As Object, email As Object
    Dim fname As String, fullpath As String
    Dim temp As String As String

    ' Create an object form the filesystem object
    Set FSO = CreateObject("Scripting.FileSystemObject")

    'set output list
    Set outlist = Range("A15")

    ' Traverse through the files
    nmail = 0
    For Each email In fileList

    ' Get the file name
    fname = email.Name
    If InStr(fname, ".eml") Then

    'look for key fields in file - this is mostly ascii
    fullpath = mailpath & "" & fname
    Open fullpath For Input As #1
    Do While (Not EOF(1))

    Line Input #1, temp
    temp2 = Trim(temp)

    'get from line
    If InStr(temp, "From: ") > 0) then
    outlist.Cells(r, 1).Value = temp
    r=r+1
    End If
    Loop
    Close #1

    Next

    End Sub
    what are the inputs to this though? already extracted mail? in what format?

    Leave a comment:


  • xoggoth
    replied
    a) Dumping the lot to excel and binning everything but the 'From' info
    Excel VBA does it quite easily. Used to do it to check order emails until they started putting everything into PDF.

    Code below is quick untested extract from a much more complicated thing so probably got a few errors, but close enough.

    'Option Compare Text
    Public r As Integer

    Private Sub CommandButton1_Click()
    Dim fold As String

    'clear list
    Range("A15:A500").Select
    Selection.ClearContents
    Range("A15").Select

    'sheet row
    r = 1

    'For each folder in list
    fol = 1
    Do
    fold = Range("C5").Cells(fol, 1).Value
    If fold <> "" Then
    getemails (fold)
    fol = fol + 1
    End If
    Range("AF2").Value = fol
    Loop While fold <> ""

    End Sub

    Sub getemails(mailpath As String)
    Dim FSO As FileSystemObject
    Dim fileList As Object, email As Object
    Dim fname As String, fullpath As String
    Dim temp As String As String

    ' Create an object form the filesystem object
    Set FSO = CreateObject("Scripting.FileSystemObject")

    'set output list
    Set outlist = Range("A15")

    ' Traverse through the files
    nmail = 0
    For Each email In fileList

    ' Get the file name
    fname = email.Name
    If InStr(fname, ".eml") Then

    'look for key fields in file - this is mostly ascii
    fullpath = mailpath & "" & fname
    Open fullpath For Input As #1
    Do While (Not EOF(1))

    Line Input #1, temp
    temp = Trim(temp)

    'get from line
    If InStr(temp, "From: ") > 0) then
    outlist.Cells(r, 1).Value = temp
    Exit Do
    End If
    r=r+1
    Loop
    Close #1

    Next

    End Sub
    Last edited by xoggoth; 26 September 2021, 11:36.

    Leave a comment:


  • gisp
    replied
    Sure.

    See the code below. Save it as .py file. It is crude but does the job.
    Change here:

    PHP Code:
    pop_conn poplib.POP3_SSL('mx.mail.com''995')
    pop_conn.user('[email protected]')
    pop_conn.pass_('password'
    It will process 100 email in 8 seconds (your speed may vary), so leave it be.
    It will put all email addresses in a text file with append option, so if it fails, delete the content of the txt file so far.
    Emails will be extracted from the 'from' header so possibly very messy. You will need to process the list in excel (other) to get rid of duplication etc.

    PHP Code:
    print >> open('emails-list.txt''a'), message['from'

    Code:
    import poplib,time
    from email import parser
    
    pop_conn = poplib.POP3_SSL('mx.mail.com', '995')
    pop_conn.user('[email protected]')
    pop_conn.pass_('password')
    
    #Get messages from server:
    stt=time.ctime()
    print 'getting messages started at %s\n' %(stt)
    
    
    messages = [pop_conn.top(i,0) for i in range(1, len(pop_conn.list()[1]) + 1)]
    
    
    endt=time.ctime()
    print 'done getting messages at %s\n' %(endt)
    
    # Concat message pieces:
    messages = ["\n".join(mssg[1]) for mssg in messages]
    
    #Parse message intom an email object:
    messages = [parser.Parser().parsestr(mssg) for mssg in messages]
    
    
    for message in messages:
    print >> open('emails-list.txt', 'a'), message['from']
    
    pop_conn.quit()
    Last edited by gisp; 26 September 2021, 08:37.

    Leave a comment:


  • Pondlife
    replied
    Originally posted by gisp View Post
    If you have POP3 access you can use python script to do this.
    there's even IMAP python, but this is overkill.
    Python script is less than 10 lines.
    No need to do 25 steps process with GBs of installation of software.
    I have the script somewhere, let me know if you want it.
    Ooh, yes please. Save faffing with VMs. Ta.

    Leave a comment:


  • gisp
    replied
    If you have POP3 access you can use python script to do this.
    there's even IMAP python, but this is overkill.
    Python script is less than 10 lines.
    No need to do 25 steps process with GBs of installation of software.
    I have the script somewhere, let me know if you want it.

    Leave a comment:


  • Pondlife
    replied
    Seems like I can install outlook onto a Win10 virtual machine and use ladymuck solution.
    Thanks

    Leave a comment:


  • ladymuck
    replied
    There seem to be tools called 'olm extractors' that will do what you want. Not being a mac user I can't say if they're scams, malware or what-not but it appears to be a common requirement to extract a variety of things from that file type.

    Leave a comment:


  • Pondlife
    replied
    Originally posted by ladymuck View Post
    Unfortunately Outlook for Mac only allows export to an '.olm' file but apart from that it's exactly what I want. Ta.

    Leave a comment:


  • ladymuck
    replied
    Does this help?

    https://www.extendoffice.com/documen...-contacts.html

    Leave a comment:


  • Pondlife
    replied
    I think I need some way of either;

    a) Dumping the lot to excel and binning everything but the 'From' info
    b) Dumping in to some sort of formatted/structured file that I can parse

    Edit: Sorry if I wasn't clear, I have a copy of all the emails locally in outlook (and airmail) - I just want to identify all the places I've signed up to over the past two decades using that address either as contact info or username.
    Last edited by Pondlife; 24 September 2021, 13:04.

    Leave a comment:


  • northernladuk
    replied
    Watching this one with interest. I'm in the same situation with my BT address. My fear is not only extracting the old ones but capturing anything that I haven't seen for awhile. Yearly reminders and the like. BT won't do a forwarding rule and I can't have the email address only if I don't use any other of their services so they only way I can make sure I've got everything is to keep the old one open for a year or two but that defeats the object of moving away from BT.

    I don't think Virgin delete their mailboxes anyway.
    I'd be very surprised at that. I know clients where they haven't closed the accounts properly but for a company offering a paid contract service I'd be very surprised. I would have thought providers would be a bit more clued up than leaving random mailboxes open. That said it's not out or realms of possibility.
    Last edited by northernladuk; 24 September 2021, 12:58.

    Leave a comment:


  • Lance
    replied
    I'd suggest extract the entire contents of the mailbox as PST file.
    Then slurp it all into Gmail (IMAP should manage that).
    Then gmail will do its thing and read all your emails and then when you try and email someone it will make a stab at the recipient.


    Or.... I don't think Virgin delete their mailboxes anyway. It's far too complex for them with all the mergers over the years and that fact that you might subscribe to all sorts of different services they offer. They're just not joined up enough.

    Leave a comment:


  • Pondlife
    started a topic Extract all sender's email addresses from emails

    Extract all sender's email addresses from emails

    I'm probably about to bin a provider (Virgin) which means I'll lose access to the email address I've used for the past twenty odd years. So I'm looking for a way to extract all the sender's email addresses from my inbox to ensure I can update with a new address (or create new logons etc). There will be 10,000 plus emails easily.

    I have Airmail (Mac), Outlook for Mac, Thunderbird (Linux) or could create a gmail acct to access.

    Any ideas on how to do so?

    TIA
    Pondy.

Working...
X