Reputation: 113
I have the below Applescript for Outlook 2011 (at bottom). I'm trying to move Inbox messages older than four months to the "on my computer" folder (on my computer of application).
When I run the script, this line always seems to return true, so it archives every message:
if time received of msg > (current date) - 4 * (4 * weeks) then
I'm posing this Nov 5, and the oldest messages in my inbox are Sep 1, so this if statement should not trigger.
Here is the Events log of a sample run:
tell application "Microsoft Outlook"
activate
get every message of inbox
count every message of inbox
current date
end tell
tell current application
current date
end tell
tell application "Microsoft Outlook"
get time received of item 1 of every message of inbox
(*time received of item 1 of every message of inbox*)
move item 1 of every message of inbox to on my computer
current date
end tell
tell current application
current date
end tell
tell application "Microsoft Outlook"
get time received of item 2 of every message of inbox
(*time received of item 2 of every message of inbox*)
move item 2 of every message of inbox to on my computer
current date
end tell
tell current application
current date
end tell
tell application "Microsoft Outlook"
get time received of item 3 of every message of inbox
(*time received of item 3 of every message of inbox*)
move item 3 of every message of inbox to on my computer
Full script:
tell application "Microsoft Outlook"
activate
if messages of inbox = {} then
error "No messages."
error -128
end if
repeat with msg in messages of inbox
if time received of msg > (current date) - 4 * (4 * weeks) then
move msg to on my computer
end if
end repeat
end tell
Upvotes: 0
Views: 902
Reputation: 19030
4 * (4 * weeks) is 4 months ago from Nov 5th, so that's about July 5th. If your time of message is Sept 1 then it surely will trigger it because Sept 1 is greater than July 5. Maybe you meant to use the less than (i.e. <) sign?
Upvotes: 2