r/applescript • • May 06 '21
Confirmation/double-check needed on code (iCloud email action)
I've used some Applescript I found to solve an issue, but hope someone can explain what it's doing:
Original Issue:
Sending and deleting iCloud emails using Windows 10 Mail will create new sent and deleted folders rather than use the existing ones (e.g. it will create a new IMAP folder called "Deleted Items" rather than allow you to put them in iCloud's "Bin" folder), so I have some AppleScript that will move contents from these folders to the proper Sent/Deleted folders when executed.
It's only ever a handful of emails in both folders, but I wanted to automate it rather than move manually every time.
Results:
it works, BUT on the MacBook I can see a message indicating it's moving hundreds of emails (and it takes a few minutes to finish), when there simply cannot be hundreds of emails to move.
Can anyone explain what's happening? Code listed below:
EDIT: inadvertent graphic removed; pasted text and source of code added
-- https://discussions.apple.com/thread/6181141
--
tell application "Mail"
\-- move Sent Items (IMAP) into Sent Messages (iCloud)
\--
set theWorkInbox to mailbox "Sent" of account "iCloud"
set TargetInbox to mailbox "Sent Items" of account "iCloud"
\-- CAPTURE REFERENCE TO EVERY MESSAGE OF MAILBOX IN A VARIABLE
set EveryMessage to every message of TargetInbox
repeat with currentWorkMessage in EveryMessage
set mailbox of currentWorkMessage to theWorkInbox
end repeatend tell
View all comments
Show parent comment
1
u/[deleted] May 06 '21
Thanks for the response - I agree the variable names are not logical! Have tried to keep the code relatively intact from where I took it