mail.app inbox

Hello people, i have been looking for a script to save all new incomming
mail to another harddrive, but i cant find anything in my search…

pt i have a script to save all mail attachment’s but i need the mail to
i was hopeing somebody got an idea for this…

Thanks

Hi mkh,

do you know Andreas Amann’s mail scripts?
A script to archive mails is included.

Hello StefanK.

Yes i have looked at it, but what i need is a script to add as a rule in my mail.app
so when i recive a new mail it auto gets downloaded to a folder… this is to be used
on a mac mini running as server…

mkh

i found this script, but i have to select the mail i want to save, :frowning:

if i could get this to save auto it would be great


on monthNumber(d)
	tell d's year to if it < 1904 then set d to d + 3.78683424E+10
	copy d to c
	set c's month to January
	(((d - c + 266917392) div 2629728) as string)'s text 2 thru 3
end monthNumber

on cleanName(t)
	tell t to if (count) > 36 then set t to text 1 thru 36
	if ":" is in t then
		set d to text item delimiters
		set text item delimiters to ":"
		set t to t's text items
		set text item delimiters to "-"
		set t to t as string
		set text item delimiters to d
	end if
	t
end cleanName

on uniqueFile(f)
	set x to f
	set n to 1
	tell application "Finder" to repeat while exists file x
		set n to n + 1
		set x to f & " (" & n & ")"
	end repeat
	x
end uniqueFile

to saveToFile(m)
	set f to uniqueFile(m's f & monthNumber(m's d) & "_" & day of m's d & "_" & year of m's d & "_" & cleanName(m's t))
	set c to m's s & return & return & m's t & return & return & m's c & return & "--end message--" as string
	set d to open for access f with write permission
	write c to d
	close access d
end saveToFile

set f to ("OS X:Users:mkh:Desktop:Mailfiles:test:") as Unicode text
tell application "Mail" to repeat with m in (get selection)
	tell {f:f} & m's {s:sender, t:subject, d:date sent, c:content} to my saveToFile(it)
end repeat


Do somebody have a hit for this to run auto

Hi mkh,

here is a common script triggered by a rule to save the contents of mail(s) into a text file (on desktop).
Each filename is generated from the sender’s name and the current date

using terms from application "Mail"
	on perform mail action with messages theMessages for rule theRule
		repeat with eachMessage in theMessages
			tell application "Mail"
				tell eachMessage
					set theSender to (extract name from sender)
					set theDate to date received
					set theContents to content as text
				end tell
			end tell
			set theDate to short date string of theDate
			set oldDelims to AppleScript's text item delimiters
			set AppleScript's text item delimiters to {"."}
			set theDate to text items of theDate
			set AppleScript's text item delimiters to oldDelims
			set theDate to text items of theDate as text
			set TempFile to ((path to desktop) as string) & theSender & "_" & theDate
			set theTextFile to open for access TempFile with write permission
			write theContents to theTextFile
			close access theTextFile
		end repeat
	end perform mail action with messages
end using terms from

:smiley:
you are great