How to export emails from Mail into a text format

I'd like to export only emails from my Spam folder into a format I can then import into Excel. All I essentially need is the Subject and From fields. Does anyone know how I can do this?

MacBook Pro unibody, Mac OS X (10.6.2), MacBook, iMac, iPhone 3GS, iPods, AirPort Extreme and Apple TV

Posted on Mar 4, 2010 10:53 AM

Reply
7 replies

Mar 11, 2010 4:33 PM in response to SacMac

This applescript will work directly into Excel:
tell application "Microsoft Excel"
set theSpamFile to make new workbook
set theSheet to active sheet of theSpamFile
set formula of range "B1" of theSheet to "Subject"
set formula of range "A1" of theSheet to "From"
end tell
tell application "Mail"
set theRow to 2
get mailboxes
set theMessages to messages of junk mailbox
repeat with aMessage in theMessages
my SetFrom(sender of aMessage, theRow, theSheet)
my SetSubject(subject of aMessage, theRow, theSheet)
set theRow to theRow + 1
end repeat
end tell
on SetFrom(theSender, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "A" & theRow
set formula of (range theRange) of theSheet to theSender
end tell
end SetFrom
on SetSubject(theSubject, theRow, theSheet)
tell application "Microsoft Excel"
set theRange to "B" & theRow
set formula of range theRange of theSheet to theSubject
end tell
end SetSubject

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to export emails from Mail into a text format

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.