TI-Troll
TI-Troll

Reputation: 3

Applescript delete mail by subject

Is there a way to delete mails by the subject, i'm trying to make an applescript that deletes mails with a certain subject from my 'Sent' mailbox. I have tried these scripts this with a test mail:

    tell application "Mail"
    set theMails to every message of (every mailbox whose name is "Sent") whose subject is "Test Mail"
delete theMails
    end tell

and:

tell application "Mail"
set theMails to {every message of inbox "Sent" whose subject is "Test Mail"}
delete theMails
end tell

Both scripts didn't work, and I didn't understand the returned errors so I could not find a solution. Help appriciated!

Upvotes: 0

Views: 646

Answers (1)

pbell
pbell

Reputation: 3095

the code bellow works. better to use word "contains" instead of trying exact match of the subject

tell application "Mail"
    set theMails to {every message of sent mailbox whose subject contains "Test Mail"}
    delete theMails 
end tell

Upvotes: 1

Related Questions