Re: Organizing mail into mail folders with Applescript?
Re: Organizing mail into mail folders with Applescript?
- Subject: Re: Organizing mail into mail folders with Applescript?
- From: Axel Luttgens <email@hidden>
- Date: Sun, 31 Jan 2010 11:45:34 +0100
Le 30 janv. 2010 à 17:36:23, Axel Luttgens a écrit :
> [...]
>
> Could you tell us whether such bulk addressing of messages on an exchange server appears to be realistic/reliable?
Anyway, before my quick attempts are lost, please find hereafter a sample handler that may answer some of your remaining questions.
It is untested, in the sense I obviously couldn't reproduce your environment.
HTH,
Axel
on MoveMessages(Y, M)
local StartDate, EndDate, YearText, MonthText, DestinationMbxPath, DestinationMbx, SourceMbx
set StartDate to current date
set time of StartDate to 0
set day of StartDate to 1
set month of StartDate to M
set year of StartDate to Y
copy StartDate to EndDate
set month of EndDate to M + 1
set YearText to (Y as text)
set YearMonthText to YearText & (text -2 thru -1 of ("0" & M))
tell application "Mail"
-- For some reason, one needs the "path notation" for creating
-- local mailboxes.
set DestinationMbxPath to "archive" & "/" & YearText
if not (exists mailbox DestinationMbxPath) then ¬
make new mailbox with properties {name:DestinationMbxPath}
set DestinationMbxPath to DestinationMbxPath & "/" & YearMonthText
if not (exists mailbox DestinationMbxPath) then ¬
make new mailbox with properties {name:DestinationMbxPath}
set DestinationMbx to mailbox DestinationMbxPath
-- Here, we assume that the treatment is to be applied to each
-- sub-mailbox of the account's inbox.
-- One needs to loop over the individual mailboxes: the "move"
-- command doesn't work with a list of lists of messages to be
-- moved.
repeat with SourceMbx in mailboxes of mailbox "Inbox" of account "email@hidden"
try
move (messages of SourceMbx whose (date received ≥ StartDate and date received < EndDate)) to DestinationMbx
on error ErrMsg number ErrNr
-- empty list of messages to be moved, timeout...
end try
end repeat
end tell
end MoveMessages
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden