1

私はApplescriptが初めてです。画像が添付されたエラー レポートを受信するためだけに存在する特定の電子メール アカウントが 1 つあります。メールボックスがすぐにいっぱいになることがあります。

2 日以上前のメールを削除するスクリプトを実行できるようにしたいので、次のスクリプトを試してみました。

別の方法を使用するのではなく、自分の過ちから学ぶことができるように、自分が書いたものを修正したいと思います. 建設的な批判を探しています:

set daysToPreserve to 2

tell application "Mail"
activate
set mailboxList to mailbox "INBOX" of account “MyAccount"
repeat with theCurrentMailbox in mailboxList
    set emailList to (every message of (mailbox theCurrentMailbox of account “MyAccount") whose date received is less than or equal to ((current date) - daysToPreserve * days))
    if (count mailboxList) is greater than 0 then
        move mailboxList to mailbox "Trash" of account “MyAccount"
    end if
end repeat
end tell

display dialog "Old Mail Messages Have Been Purged" buttons ["OK"]
4

3 に答える 3

1

あなたの編集はうまくいきました。ダイアログを前面に表示するようにスクリプトを編集しました。

set daysToPreserve to 2
set myAcount to "MyAccount"
set dateReference to (current date) - (daysToPreserve * days)

tell application "Mail"
  activate
  set myMailbox to mailbox "INBOX" of account myAcount
  set accountTrash to mailbox "Trash" of account myAcount
  set messagesToDelete to messages of myMailbox whose date received ≤ dateReference
  repeat with aMessage in messagesToDelete
  move aMessage to accountTrash
end repeat
end tell

tell current application
  activate
  display dialog (count messagesToDelete) & " old Mail Messages Have Been Purged" as    text buttons ["OK"]
end tell
于 2014-03-15T23:43:06.683 に答える
1

これで1つのアイテムを繰り返しブロックに入れます:

set mailboxList to mailbox "INBOX" of account “MyAccount"
repeat with theCurrentMailbox in mailboxList

次のようなことを試すことができます:

set daysToPreserve to 2
set myAcount to "MyAccount"
set dateReference to (current date) - (daysToPreserve * days)

tell application "Mail"
    activate
    set myMailbox to mailbox "INBOX" of account myAcount
    set accountTrash to mailbox "Trash" of account myAcount
    set messagesToDelete to messages of myMailbox whose date received ≤ dateReference
    repeat with aMessage in messagesToDelete
        move aMessage to accountTrash
    end repeat
end tell

display dialog (count messagesToDelete) & " old Mail Messages Have Been Purged" as text buttons ["OK"]
于 2014-03-15T15:08:56.650 に答える