Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

Jagra

macrumors newbie
Original poster
Feb 17, 2010
1
0
I have a rule in Mail, which moves specific emails to a specific email folder: "TestSpecs".

Now I need an AppleScript to run in conjunction with the rule, which will save each email as a txt file in a folder on my desktop.

I get this far (not very far I know) now it has me stuck.
set theFolder to "/Users/Jagra/Desktop/TestSpecs" as string

tell application "Mail"
activate
????
end tell

Can anyone suggest how I go about this?
 

kainjow

Moderator emeritus
Jun 15, 2000
7,958
7
This is pulled from a script I use. It's the basic outline to get you started:

Code:
on perform_mail_action(theData)
	tell application "Mail"
		set theSelectedMessages to |SelectedMessages| of theData
		repeat with theMessage in theSelectedMessages
			try
				-- process theMessage
			on error theError
				display dialog "ERROR: " & theError
			end try
		end repeat
	end tell
end perform_mail_action

That function gets called by Mail. Now you need to figure out how to get the email message as plain text and how to write that to a file. I suggest first start googling around as those are simple tasks. Also in AppleScript Editor, go to File > Open Dictionary and select Mail to see what you can do with a message.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.