Domanda

Ho scritto un semplice AppleScript che loop a tempo indeterminato all'interno Entourage Posta in arrivo e ottiene soggetti di messaggi "non letti":

tell application "Microsoft Entourage"
activate

repeat with eachMsg in messages of folder named "Inbox"
    if read status of eachMsg is untouched then
        set messageSubject to subject of eachMsg as string

        -- bla bla bla

        -- How to delete the message and proceed with the next one???
    end if

end repeat

Ora, il problema è, voglio eliminare i messaggi dopo avere ottenuto il soggetto. Come posso fare questo? La prego di scrivermi un esempio?

Grazie ancora!

È stato utile?

Soluzione

Una volta che si elimina un messaggio, si hanno cambiato la lunghezza della lista dei messaggi, quindi ad un certo punto, si sta per imbattersi in un indice che non esiste più perché è stato eliminato abbastanza messaggi. Per aggirare il problema, è necessario (essenzialmente) codificare il ciclo; ottenere il conteggio dei messaggi, e ripartire da l'ultimo messaggio e passare da lì. Anche se è stato eliminato un messaggio, gli indici sopra quella attuale sarà sempre intatto. Non testato, ma è un modello che ho usato altrove ...

tell application "Microsoft Entourage"
activate
set lastMessage to count messages of folder named "Inbox"
repeat with eachMsg from lastMessage to 1 by -1
    set theMsg to message eachMsg of folder named "Inbox"
    if read status of theMsg is untouched then
        set messageSubject to subject of theMsg as string

        -- bla bla bla

        -- How to delete the message and proceed with the next one???
    end if

end repeat

sintassi "convenienza" di Applescript a volte non è, ed è per questo Io di solito evitare del tutto.

Altri suggerimenti

Ecco uno snippit da un esempio a pagina Entourage l'aiuto di Microsoft (in particolare lo script "Nuke Messaggi"):

repeat with theMsg in theMsgs
    delete theMsg -- puts in Deleted Items folder
    delete theMsg -- deletes completely
end repeat 
Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top