How to save contents of many emails to individual files?

Discussion in 'Mac Programming' started by iHateMacs, Sep 7, 2011.

  1. iHateMacs, Sep 7, 2011
    Last edited: Sep 7, 2011

    iHateMacs macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #1
    Can someone point me in the right direction here.

    Is what I am asking below possible to do in Automator or Applescript? (whichever is simplest)

    I have hundreds of emails (EDIT 5000 !). Each one contains an XML representation of an order placed through our website.

    Later on I want to parse the XML and get customer data from it, but first I need to save all these emails as individual files.

    So all I need to automate is the saving of the contents of each email into a file. The file can be named anything, it doesn't matter. A sequential number would be ideal, but doesn't matter.

    Can this saving of emails be done with automator/applescript or is there a better way? Anything is better than cutting and pasting each one.
     
  2. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #2
    If you are using Apple Mail then, most likely, the messages are already some where in ~Library/Mail in .emlx format. For example, for me, in ~Library/Mail/Mac-robbieduncan/Forums/MacRumors.imapbox I currently have 19844 .emlx files, one for each mail in that mailbox.

    The .emlx format is plain text and looks OK to extract the contents from...
     
  3. iHateMacs thread starter macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #3
    Thanks for that. I didn't know.

    I don't understand the hierarchy, but as all my data is XML I should be able to look through all the files and grab what I need.

    At least they are all in one account so that will reduce the number of files.

    Thanks again.
     
  4. iHateMacs thread starter macrumors 6502a

    iHateMacs

    Joined:
    Aug 13, 2008
    Location:
    Coventry, UK
    #4
    After all that I have found an even simpler way DOH!

    Select the emails in large groups (1000 at a time seems to work ok) then choose FORWARD. When the new email opens up copy and paste into a text file.

    I only had to do that 5 times.
     
  5. robbieduncan Moderator emeritus

    robbieduncan

    Joined:
    Jul 24, 2002
    Location:
    London
    #5
    Even better :)
     

Share This Page