• Apfeltalk ändert einen Teil seiner Allgemeinen Geschäftsbedingungen (AGB), das Löschen von Useraccounts betreffend.
    Näheres könnt Ihr hier nachlesen: AGB-Änderung
  • Viele hassen ihn, manche schwören auf ihn, wir aber möchten unbedingt sehen, welche Bilder Ihr vor Eurem geistigen Auge bzw. vor der Linse Eures iPhone oder iPad sehen könnt, wenn Ihr dieses Wort hört oder lest. Macht mit und beteiligt Euch an unserem Frühjahrsputz ---> Klick

Bestimmte Email filtern vorlesen und löschen

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
Hallo liebes Forum Team,

Ich bin neu hier und komme bei meinem Applescript nicht mehr weiter!

Ich möchte in meinem iCloud Posteingang mit einer Regel ein Applescript ausführen damit mit der Betreff vorgelesen wird und dann die Email gelöscht wird.

Das hier habe ich bereits zusammen gebastelt

1er Ansatz

Code:
— neue ungelesene mail und filtert Betreff

tell application "Mail"
set ungelesen to every message in mailbox "INBOX" of account "iCloud" whose read status is false
set z to random number from 1 to count ungelesen
set betreff to (subject of (item z of ungelesen))
end tell

— Betreff filtern
set stringContainsName to false
set tString to "HomeMatic"
repeat with aName in paragraphs of betreff
if tString is in betreff then set stringContainsName to true
end repeat
if stringContainsName then
(say betreff using "Markus")
else
(say "test" using "Markus")

end if

2er Ansatz

Code:
set searchWord to "HomeMatic:"

set emailAddress to "iCloud"

tell application "Mail"

set theSubjects to subject of messages of mailbox "INBOX" of account emailAddress whose read status is false

end tell

set paraCounter to 1

repeat with i from 1 to count of theSubjects

set thisSubject to item i of theSubjects

if thisSubject contains searchWord then

(say thisSubject using "Markus")

end if

end repeat
 

Pill

Adams Parmäne
Registriert
07.07.12
Beiträge
1.310
Hallo,

die Regel sollte so aussehen:
bildschirmfoto-2015-04-08-um-11-35-30-png.120211

und das AppleScript so:

Code:
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        tell application "Mail"
            repeat with aMessage in theMessages
                say (subject of aMessage as rich text) using "Markus"
            end repeat
            delete theMessages
        end tell
    end perform mail action with messages
end using terms from

Eventuell musst du die Mails auch in den Trash verschieben, anstatt sie zu löschen.
 

Anhänge

  • Bildschirmfoto 2015-04-08 um 11.35.30.png
    Bildschirmfoto 2015-04-08 um 11.35.30.png
    67,8 KB · Aufrufe: 185

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
Pill,

vielen Dank du hast mir sehr weiter geholfen ! ! !

lg Joni-Blue
 

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
hi Pill,

jetzt habe ich doch nochmal eine Frage!

ich habe dein script erweitert das es die Musik in iTunes oder Spotify pausiert und er dann vorliesst und danach wieder
die Musik einschaltet. wenn jetzt aber Spotify und iTunes gleichzeitig auf Play sind höre ich die ansage 2 mal!!!

magst du da nochmal rüber schauen?

Code:
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
       
       
       
        if application "iTunes" is running or application "Spotify" is running then
            tell application "iTunes"
                if player state is playing then
                    stop
                    tell application "Mail"
                        repeat with aMessage in theMessages
                            say (subject of aMessage as rich text) using "Markus"
                        end repeat
                        delete theMessages
                    end tell
                    play
                end if
            end tell
            tell application "Spotify"
                if player state is playing then
                    pause
                    tell application "Mail"
                        repeat with aMessage in theMessages
                            say (subject of aMessage as rich text) using "Markus"
                        end repeat
                        delete theMessages
                    end tell
                    play
                end if
            end tell
        else
            tell application "Mail"
                repeat with aMessage in theMessages
                    say (subject of aMessage as rich text) using "Markus"
                end repeat
                delete theMessages
            end tell
        end if
        tell application "Spotify"
            if player state is paused then
                tell application "iTunes"
                    if player state is paused then
                        tell application "Mail"
                            repeat with aMessage in theMessages
                                say (subject of aMessage as rich text) using "Markus"
                            end repeat
                            delete theMessages
                        end tell
                    end if
                end tell
            end if
        end tell
       
       
       
    end perform mail action with messages
end using terms from

danke dir
 

maddi06

Borowitzky
Registriert
10.11.14
Beiträge
9.027
Kannst du das ganze nicht abkürzen? DEr soll doch sofort schauen ob iTunes oder / oder Spotify an ist und auf Pause setzen. Der letzte Ratenschwanz kann dann damit weg.
 

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
Der ist dafür das wenn die auf Pause stehen dann soll ja auch der Betreff vorgelesen werden
 

Pill

Adams Parmäne
Registriert
07.07.12
Beiträge
1.310
So sollte es gehen:

Code:
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
      
        set itunesPaused to false
        set spotifyPaused to false
      
        -- iTunes und Spotify bei Bedarf pausieren
        if application "iTunes" is running then
            tell application "iTunes"
                if player state is playing then
                    pause
                    set itunesPaused to true
                end if
            end tell
        end if
        if application "Spotify" is running then
            tell application "Spotify"
                if player state is playing then
                    pause
                    set spotifyPaused to true
                end if
            end tell
        end if
      
        -- Betreff vorlesen und Nachrichten löschen
        tell application "Mail"
            repeat with aMessage in theMessages
                say (subject of aMessage as rich text) using "Markus"
            end repeat
            delete theMessages
        end tell
      
        -- iTunes und Spotify bei Bedarf wieder starten
        if itunesPaused then
            tell application "iTunes" to play
            set itunesPaused to false
        end if
        if spotifyPaused then
            tell application "Spotify" to play
            set spotifyPaused to false
        end if
      
    end perform mail action with messages
end using terms from
 

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
Nochmal zu dem mail löschen,. So wie es jetzt ist löscht er die Mail nur auf dem iMac nicht aber auf dem iPhone (icloud) wie kann ich das ändern?
 

Joni-blue

Gala
Registriert
21.03.12
Beiträge
53
Danke hab es schon hinbekommen, allen einen schönen Sonntag