Лучший способ удалить все вложения во всех сообщениях в конкретном почтовом ящике - PullRequest
1 голос
/ 01 ноября 2019

Я новичок в AppleScript и пытаюсь написать скрипт, который удалит все вложения во всех сообщениях в указанном почтовом ящике (Mail.app).

Вот что я пытаюсь:

tell application "Mail"
    tell mailbox "Sent" of account id "<XXX>"
        set ListMessage to get every message
        repeat with aMessage in ListMessage
            set aList to get every mail attachment of aMessage
            repeat with aFile in aList
                if (downloaded of aFile) then
                    delete aFile -- this gives an error
                end if
            end repeat -- next file
        end repeat -- next message
    end tell
end tell

Запуск этого приводит к ошибке:

Error: the Apple Event handler failed (errAEEventFailed:-10000)

Что я делаю не так?

Спасибо!

1 Ответ

0 голосов
/ 07 ноября 2019

Оказывается, что delete не работает с почтовыми вложениями, но есть альтернативный способ решения проблемы: вы можете щелкнуть пункт меню Remove Attachments с помощью системных событий:

tell application "Mail"
    activate
    every item of (get selection)
end tell
tell application "System Events" to click menu item "Remove Attachments" of menu "Message" of menu bar item "Message" of menu bar 1 of process "Mail"
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...