// Export Apple Mail Messages and Notes to Text Files

I saw a Tweet from Scott Paterson, asking if there was an AppleScript to quickly batch export Notes from Apple Mail into individual text file.

Well Scott — If there wasn’t one before, there is now!

Features

  • This AppleScript will export any selected Messages or Notes in Apple Mail as individual text files to a temporary folder on your Desktop (called “Temp Export Folder”);
  • The script also attempts to remove any “illegal characters” from the file name as to avoid the process grinding to a complete halt!
  • If you have Growl installed, the script should detect it and notify you when your export is completed.

Current Limitations and Open Issues

(Otherwise known as “Places Where You Could Help Out!”)

  • I kept the output very basic — only spitting out the content of the note/message as the content of the text file. It *IS* possible to add more information from the messages and, if people are interested in that, let me know!
  • Errors that will undoubtedly arise when you do something that I didn’t think of or test for! ;)

How to Install and Use

As of Version 1.1, the source code and instructions are moving to the Veritrope.com Code Library:

CLICK HERE TO GET THE SCRIPT AND SEE THE SOURCE CODE!

Found a bug in the script?

Click Here To Submit Your Bug Report!

Interested in what other AppleScripts are available on Veritrope.com?

Click here to see the latest list!

18 Responses to “Export Apple Mail Messages and Notes to Text Files”

  1. Twitter Comment


    Thanks to @veritrope for knocking up AppleScript to export Notes to text files from Mail.app [link to post]

    Posted using Chat Catcher

    • D says:

      Thanks for putting this together. Two things: 1) Can I have the original dates exported with the notes? 2) The script fails because it requires Growl which I don’t have installed (I don’t really have a need for Growl). Do you have a version of the script that doesn’t need Growl?

      • Justin says:

        The Growl issue must be a bug — it’s supposed to detect whether or not you have it installed and adjust. Click here to file a bug report so that I don’t lose track of it and, when I’m working on a new revision, I’ll spend some time on this!

        A question: How would you want the original dates presented? As a header at the top of the note?

        • lydia says:

          for me, it would be useful to have basic messages headers placed at the top of each txt file. would love to see at least “From:”, “Subject:”, and “Date:”. would that be easy to add if i knew what i was doing?

          (i am about to take off on a big trip, am trying to create an archive of the relevant mail folder, don’t really have time to delve into learning applescript just now.)

  2. Danny says:

    You just saved me about an hour. Thank you.

  3. ERicb says:

    Thanks !! Perfect for converting email to text so that the new (Dragon ) Dictate can learn writing style / vocab!! This saved me TONS of time / training…

    Thank you again!!

    EricB

    • Justin says:

      Thanks — and I think that’s a really great way to use this script!

      I’d love to use it the same way myself and I even reached out a few weeks ago to Dragon to send me a review copy so I could also try some direct scripting… Guess I’ll have to wait for them to offer that promised crossgrade from the PC version! ;)

      One way or another, I think I’ll have some Dragon scripts up sometime in the near future…. and if you come up with any of your own, please use the submission page to share them with all of us!

  4. Morgan says:

    Thank you! Thank you! This is exactly what I needed!

    • Kevin says:

      This was a very helpful tool, thanks! On my Mac running 10.5.8, I commented out the 32-character filename limit, removed the illegal character filter (except “:”), and removed the “.txt” filename suffix. Then I was able to use it to export 600 Notes from Apple Mail to the temp folder, then import everything in that temp folder to my Mark/Space Notebook then synchronize them into the Fliq notebook app on my Samsung Galaxy S Captivate (Android 2.1) using The Missing Sync for Android. Whew!

      It would be nice to have parameters at the top of the the script to choose the file naming validation based on the operating system.

  5. Hans Erik says:

    Hi Justin,

    This certainly is a timesaver.
    One problem I encountered: whenever two messages have the same name, the first is written over by the second. So I took a deep breath and changed the a little, by adding a counter, that is attached to the filename:

    set msgnr to 1
    ...
    repeat etc.
    ....
    set theFilePath to (SaveLoc & msgnr & "_" & theFileName & ".txt")
    set msgnr to msgnr+1
    end repeat

    etc.

    Hans Erik

  6. Rick Bennett says:

    This little script saved my bacon. Man, I think it’s crazy that Apple doesn’t have an “export messages” button under their Mail/File menu.

  7. albarn says:

    why do you have to prefix the text files with number and underscore?????

  8. albarn says:

    nevermind.. i’ve removed your portion of code that adds the prefix.

rss Subscribe to Comments RSS Feed


Trackbacks/Pingbacks

  1. Snow Leopard Issue With Mail, Exchange, and AppleScript rule | Veritrope
  2. AppleScript, MacHeist, Scottevest, Tavo, Hella, and Schneier | Veritrope
  3. Esportare messaggi da Apple Mail in formato testo - Laboratori EL-Tech
  4. Simple steps to move your data away from MobileMe

You can use these tags in your comment: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>