Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

RLRL

macrumors member
Original poster
Jan 31, 2015
77
6
Catalina iMac,


I have a script that deletes SpamSieve Spam from Mac Mail Spam Mailbox, works really well with smaller Spam Mailboxes that with less than 300 spams emails.

However with large Spam Mailboxes with 600 or more Spam emails it times out before completing.

I was trying to place a Timeout in the code but do not understand how to code it.
I can not it compile or run.

Here is the Script file.

I was trying to use timeout command but can not make it work.

Can someone help me with this.

I need to give the script about 300 seconds to complete.
 

Attachments

  • Discard Spam.txt
    11.2 KB · Views: 8
Looks like it doesn't compile when you wrap the on block in a timeout block. I moved the timeout block to be inside the on block, like so:

AppleScript:
on run {}
    with timeout of 300 seconds
        tell application "Mail"
            my completelyDeleteMessagesFromMailbox(my spamMailbox())
        end tell
        
    end timeout
end run

Fair warning: it's been many years since I've touched AppleScript. I do not have SpamSieve so I am unable to test the code anyways, but this does compile.

You may need to add the timeout block to each on block. Or maybe it's just one function that's timing out.
 
Thank you, how do I code and give the whole script, all functions in the script, at least 5 minutes to complete.

What code do I need for entire script, and where do I insert it?

Thanks
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.