Does anybody know how to do this?
tell application "Mail"
set msgs to selection
tell account "iCloud"
set mailbox of msgs to "junk"
end tell
end tell
I tried this, but got this:
error “Can’t set «class mbxp» of {} to "junk".” number -10006 from «class mbxp» of {} to «class junk»
Any ideas?
Thanks
You are trying to set a mailbox object to a literal string which is not possible.
Like in the Finder you have to move the messages
tell application "Mail"
set msgs to selection
move msgs to mailbox "junk" of account "iCloud"
end tell
If it does not work to move all selected messages in one line use a repeat loop
Thank you so much!!! My email organiser works now, so I thought I would give it back to the group.
This will keep my emails so much more organised.
J
--
-- Email move script
-- You can either search for part or whole of a email address then move it
-- to a folder or junk it
-- Shedule this script, every week or nightly to keep your email organised!!!
on run
--mess_han("email address", "folder")
mess_han("nike", "Junk")
end run
on mess_han(person, place_to)
try
tell application "Mail"
tell inbox
set theMessage to messages whose sender contains person
end tell
repeat with this_message in theMessage
move this_message to mailbox place_to of account ("iCloud")
end repeat
end tell
end try
end mess_han