Jump to content
jav1231

Printing your email lists

Recommended Posts

Does anyone know a way of printing your list of emails? More importantly, I'd like to parse the sender/subject/etc into a spreadsheet. I can archive this and get a "table of contents" but that file is rife with code data. Ideas?

Share this post


Link to post
Share on other sites

I don't know how to do that, but am curious about the purpose?

 

The search function in email works pretty well for finding pretty much anything.

Share this post


Link to post
Share on other sites
I don't know how to do that, but am curious about the purpose?

 

The search function in email works pretty well for finding pretty much anything.

 

In my case, I'm dumping mail from a specific form into a mailbox. I want to be able to push the contents of the list to a spreadsheet so I can track "from" information etc. to build a list. IOW, a spreadsheet of everyone who sent mail to this mailbox which in this case is actually a folder that is filtered via a rule. Otherwise, I'll have to manually type all this in. :( No bueno!

Share this post


Link to post
Share on other sites

Sounds like a job for an AppleScript.

 

Copy & paste the following into a window in your Script Editor app (from your /Application/AppleScript folder.)

Select "Save as..." to store it someplace on your Mac.

In Mail, select the messages you want to export. (If you want the whole mailbox, open the mailbox and select All in the list pane.)

Click "Run" in the Script Editor. Pick a file name.

This writes a tab-separated list of your mail for import into a spreadsheet.

 

 


-- function to strip tabs from text
on stripTabs(txt)
set AppleScript's text item delimiters to tab
set theChars to the text items of txt
set AppleScript's text item delimiters to space
set txt to ("" & theChars)
set AppleScript's text item delimiters to {""}
return txt
end stripTabs

tell application "Mail"
activate

set theMessages to the selection
set msgCount to (the count of theMessages)

-- get the name of output file:
repeat
	display dialog "Please enter name of output file (on desktop):" default answer "mail_list.txt" buttons {"Cancel", "OK"} default button 2
	set the outFileName to the text returned of the result
	if the outFileName is not "" then exit repeat
end repeat

-- open the output file on desktop for writing:
set theTextFile to (((path to desktop) as string) & outFileName) as file specification
open for access theTextFile with write permission
set eof of theTextFile to 0


-- process each selected message
repeat with theMsg in theMessages

	set msgSender to the sender of theMsg
	set msgSubject to the subject of theMsg

	-- make sure there are no tabs in 
	set msgSubject to stripTabs(msgSubject) of me
	set msgSender to stripTabs(msgSender) of me

	-- write sender and subject to file, separated by TAB		
	write (msgSender & tab & msgSubject & return) to theTextFile

end repeat

-- close the output file
close access theTextFile

end tell

 

Because I'm lazy, this always creates the file to your desktop.

Since you only specified Sender and Subject, that's all it exports. I'm not good with "etc." because I have no imagination. It can be expanded if you like.

(Tested on OSX 10.5.7 with Mail 3.6. I didn't actually test with a message whose subject contains a tab, since I didn't have one handy. So that remains only a theoretic feature. Not even sure if a tab is valid in an RFC822 subject line.)

Edited by car1son

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing

    No registered users viewing this page.

  • Who's Online (See full list)

    There are no registered users currently online

×