Re: Mail problems with special characters
Re: Mail problems with special characters
- Subject: Re: Mail problems with special characters
- From: Christian Walther <email@hidden>
- Date: Wed, 12 Mar 2003 09:53:44 +0100
>
Could you send me a full copy of your script and a screenshot of your
>
mailboxes drawer (showing the mailbox(es)) that are tripping up the
>
script?
Screenshot:
[demime 0.98b removed an attachment of type image/tiff which had a name of pastedGraphic2.tiff]
This is the test script that demonstrates the problem:
tell application "Mail"
mailbox "02 Februar"
mailbox "03 M
rz"
mailbox "2003/02 Februar"
mailbox "2003/03 M
rz"
end tell
(* the event log of this script looks like this:
tell application "Mail"
get mailbox "02 Februar"
mailbox "2003/02 Februar"
get mailbox "03 M
rz"
mailbox "2003/03 M
rz"
get mailbox "2003/02 Februar"
mailbox "2003/02 Februar"
get mailbox "2003/03 M
rz"
end tell
nothing is returned from the last statement! *)
This is the original mail sorting script that worked in January and
February, but not in March:
on perform_mail_action(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
set theRule to |Rule| of info
repeat with theMessage in selectedMessages
my handleMessage(theMessage)
end repeat
-- lacking outgoing mail rules, sort outgoing mail here:
repeat with theMessage in (get every message of mailbox "Sent Messages" of
account "GMX")
my handleMessage(theMessage)
end repeat
end tell
end perform_mail_action
on handleMessage(theMessage)
tell application "Mail"
set d to date sent of theMessage
-- this is to be used with german date format:
set boxname to word 4 of (d as string) & "/" & (text from character -2 to
end of ("00" & (my getMonth(d) as string))) & " " & word 3 of (d as string) --
e.g. "2003/03 M
rz"
-- this works if the mailbox name only contains ascii chars (such as
"2003/01 Januar" or "2003/02 Februar"), but not otherwise (e.g. with "2003/03
M
rz):
if not (exists mailbox boxname) then make new mailbox with properties
{name:boxname}
set mailbox of theMessage to mailbox boxname
end tell
end handleMessage
property monthconsts : {January, February, March, April, May, June, July,
August, September, October, November, December}
on getMonth(d)
set m to month of d
repeat with i from 1 to 12
if m is item i of monthconsts then return i
end repeat
end getMonth
This is the worked around mail sorting script that works now, but won't
work anymore as soon as there are mailboxes for the same month in
different years:
on perform_mail_action(info)
tell application "Mail"
set selectedMessages to |SelectedMessages| of info
set theRule to |Rule| of info
repeat with theMessage in selectedMessages
my handleMessage(theMessage)
end repeat
-- lacking outgoing mail rules, sort outgoing mail here:
repeat with theMessage in (get every message of mailbox "Sent Messages" of
account "GMX")
my handleMessage(theMessage)
end repeat
end tell
end perform_mail_action
on handleMessage(theMessage)
tell application "Mail"
set d to date sent of theMessage
-- this is to be used with german date format:
set boxname to word 4 of (d as string) & "/" & (text from character -2 to
end of ("00" & (my getMonth(d) as string))) & " " & word 3 of (d as string) --
e.g. "2003/03 M
rz"
-- working around the bug: shortboxname (without the "2003/") succeeds in
addressing mailboxes with non-ascii chars, whereas boxname doesn't (but
shortboxname won't be unique as soon as there's a mailbox for the same month
in another year (which isn't the case yet)):
set shortboxname to (text from character -2 to end of ("00" & (my
getMonth(d) as string))) & " " & word 3 of (d as string) -- e.g. "03 M
rz"
if not (exists mailbox shortboxname) then make new mailbox with properties
{name:boxname}
set mailbox of theMessage to mailbox shortboxname
end tell
end handleMessage
property monthconsts : {January, February, March, April, May, June, July,
August, September, October, November, December}
on getMonth(d)
set m to month of d
repeat with i from 1 to 12
if m is item i of monthconsts then return i
end repeat
end getMonth
Thanks for having a look.
-Christian
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.