Trying to purge deleted mails from some IMAP accounts

I would like to purge deleted mails from some IMAP accounts. I wrote the following script and tested it from AppleScript editor (on MacOS 9). It runs perfectly. As soon as I wanted to call it directly from the Outlook Express Scripts Complements, I have the following message: “Outlook Express error: timeout for an AppleEvent”. Could you please help me?

Script (written to run with French OE):

on run
tell application “Outlook Express” to set imapAccountNames to name of IMAP accounts
tell application “Outlook Express”
repeat with i from 1 to number of items in imapAccountNames
set IsInSendAndreceiveAll to include in send and receive all of IMAP account (item i of imapAccountNames)
if IsInSendAndreceiveAll is true then
set imapAccountFolders to folders of IMAP account (item i of imapAccountNames)
repeat with f from 1 to number of items in imapAccountFolders
set folderID to ID of (item f of imapAccountFolders)
with timeout of 30 seconds
open folder id folderID
end timeout
with timeout of 30 seconds
– Select “Purge deleted mails” from “Edit” menu
Select Menu Item menu title “Édition” menu item text “Vider le dossier des éléments supprimés”
end timeout
with timeout of 30 seconds
– Select “Close” from “File” menu
Select Menu Item menu title “Fichier” menu item text “Fermer”
end timeout
end repeat
end if
end repeat
end tell
end run

Franck,

Are you using some sort of scripting addition to select menu items or is that in the French OE dictionary?

I don’t see that you are activating Outlook Express, so maybe adding the activate command to bring OE to the front before trying to control menu’s may help?

Also, maybe give your script more than 30 seconds to timeout?

Otherwise, OE does let you configure IMAP accounts to purge IMAP trash folders on Quit. Then all you’d have to do is quit and relaunch OE.

Hope this helps,

I’m using Menu Event Scripting Addition to activate the menu item as OE does not provide a way to do this.

About OE activation, all commands (ie loop on IMAP account, …) are enclosed in a block begining with "tell application “Outlook Express” … “end tell”. Is it not enough?

I know that I can configure the IMAP accounts to purge “themselve” deleted emails, but quitting and lauching OE take at least 1 minute on my computer as I have a lot of accounts (I’m the administrator of our email server).

About 30 seconds timeout, the error message given by OE is displayed in less than 1 second, so I don’t think that giving more than 30 seconds will change this.

Thank you for your help.

Franck,

Enclosing commands directed at OE within a Tell OE block is enough but you are telling your Menu Events OSAX to hit an OE menu. If OE is not the front most app I’m sure Menu Events won’t find that menu. - Anyway, It’s worth a shot.

I don’t have that addition but I have worked with similar and know if you are trying to hit a menu it should be in the foreground.

Regarding the placement of your timeout - maybe try placing 1 timeout command around the entire script instead of just around the area where you are opening mail folders.

on run
with timeout of 30 seconds--or more if you have a lot mail admin stuff to do
tell application "Outlook Express"
--your script
end tell
end timeout
end run

Just a suggestion Franck. Maybe someone else knows how to directly purge IMAP folders. If not - and you don’t have to be in front of the computer during that 1 minute, it is something to consider.

Best of luck.