Fehlfunktion bei Mail-Regeln

In Mail.app kann ich Regeln definieren. Darüber kann ich empfangene Mails an DEVONthink übergeben, das klappt auch einwandfrei.

Was nicht klappt, ist das Übergeben verschickter Mails. Was läuft hier falsch?

Wird denn die Regel überhaupt ausgeführt? Z.B. der erste Schritte oder eine andere Aktion wie das Abspielen eines Tons? Das Skript selbst leitet nur die von Apple Mail erhaltenen Daten an DEVONthink weiter, dabei sollte eigentlich nichts schief gehen (sofern es korrekte Daten von Mail erhält)

Ja, sie wird ausgeführt (im Screenshot allerdings deaktiviert). Jedenfalls, wenn ich über das Menü gehe und “Regel anwenden” wähle. Aber von alleine läuft sie nicht - im Gegensatz zur Regel für die hereinkommenden Mails (die ist genauso aufgebaut und läuft einwandfrei).

Wenn ich eine andere Aktion wähle (z.B Markieren), klappt das auch einwandfrei, nur eben das Verschieben nach DEVONthink will nicht

Soweit ich mich erinnere, werden von Apple Mail bisher beim Senden Regeln nicht automatisch ausgeführt.

Mail-Regeln werden für eingehende oder bestehende E-Mails ausgeführt, nicht für ausgehende.

(Übersetzt mit deepl.com)

Gut, das erklärt natürlich alles.

Beim Senden ist der automatische Transfer von Mails an DEVONthink auch gar nicht so wichtig. Da man beim Senden ohnehin im Mail-Programm ist, kann man die Regel auch manuell anstoßen

Ich hatte gehofft, es ginge automatisch

Hallo,

lad Dir doch mal Mail Act on runter. Kostet zwar ne Mark, aber hier kannst Ausgangsregeln definieren.
Dann erstellst Du noch dieses Script und fügst es zu Mail dazu:

– POSIX path of destination database. Global inbox is used if not specified.
property pDatabasePath : “/pfad/mein passender Ordner.dtBase”

– This string is used when the message subject is empty
property pNoSubjectString : “(no subject)”

using terms from application “Mail”
on perform mail action with messages theMessages for rule theRule
tell application id “DNtp”
if pDatabasePath is “” then
set destination_database to inbox
else
set destination_database to open database pDatabasePath – Ensure that the database is open
end if
end tell

  tell application "Mail"
     set theFolder to (POSIX path of (path to temporary items))
     repeat with theMessage in theMessages
        try
           tell theMessage
              set {theDateReceived, theDateSent, theSender, theSubject, theSource, theReadFlag} to {the date received, the date sent, the sender, subject, the source, the read status}
              
              -- Location of message
              set theMessageLocation to "/"
              try
                 set theMailbox to mailbox of theMessage
                 repeat while theMailbox is not missing value
                    set theName to name of theMailbox
                    set theMessageLocation to "/" & (theName as string) & theMessageLocation
                    set theMailbox to container of theMailbox
                 end repeat
              end try
              set theMessageLocation to "/Apple Mail" & theMessageLocation
           end tell
           
           set numAttachments to count of mail attachments of theMessage
           if theSubject is equal to "" then set theSubject to pNoSubjectString
           
           tell application id "DNtp"
              set message_group to create location theMessageLocation in destination_database
              create record with {name:theSubject & ".eml", type:unknown, creation date:theDateSent, modification date:theDateReceived, URL:theSender, source:(theSource as string), unread:(not theReadFlag)} in message_group
              if numAttachments > 0 then set attachment_group to create location theMessageLocation & "/Attachments" in destination_database
           end tell
           
           repeat with theAttachment in mail attachments of theMessage
              set theFile to theFolder & (name of theAttachment)
              tell theAttachment to save in theFile
              tell application id "DNtp"
                 set theAttachmentRecord to import theFile to attachment_group
                 set unread of theAttachmentRecord to (not theReadFlag)
                 set URL of theAttachmentRecord to theSender
              end tell
           end repeat
        end try
     end repeat
  end tell

end perform mail action with messages
end using terms from

Gruß Rippchen mit Kraut