OSX attachment saving

Hello!

Sorry for the new thread, but I read a lot of posts about mail attachment saving, but didn’t find any useful for me.

I’m very new in Mac’s world, olny last week shifted from PC. There i had to used TheBat! for mailing and i was very content with filtering options.

I’m just downloaded some AppleScript references, but I hope someone can easily help form me here.

The problem is the next:

I have a homepage, witch dump down daliy a mysql database and sends me with always the same subject.
The mail contains a gzip file with filename of the current day (for example: 20_10_2007.sql.gz)

I have a partition for my works next to Tiger, called Data.
So I would like to get all the attachments of this emails saved to a presecified folder in Data partition, then automaticly delete the message. It would be good if all this should be happened automaticly when i get the incoming mail.

If you have any idea, pls help me.

Thanks,

Daniel

Hi Daniel,

welcome to MacScripter.
Try this, adjust the path in the property line (the colon at the end is crucial),
then define a rule in Mail.app and attach the script to this rule.

property destinationFolder : "Data:path:to:Folder:"

using terms from application "Mail"
	on perform mail action with messages theMessages
		tell application "Mail"
			repeat with oneMessage in theMessages
				try -- if an error occurs the message will not be deleted
					repeat with oneAttachment in mail attachments of oneMessage
						save oneAttachment in destinationFolder & name of oneAttachment
					end repeat
					delete oneMessage
				end try
			end repeat
		end tell
	end perform mail action with messages
end using terms from

Sorry, but can you give me an example for this:

property destinationFolder : “Data:path:to:Folder:”

Data is the name of your volume.
Macintosh HFS paths are colon separated.

If you want to address a folder e.g.

folder downloads of folder mystuff of disk Data

you have to write:

property destinationFolder : "Data:mystuff:downloads:"

I see now, this colon separated path was not clear for me. Tthanks your kindness, I’ll try the code now.

the script works… thanks :slight_smile: