Script für Sicherung von E-Mail Anhängen funktioniert nicht
Hallo, aus ca. 100 E-Mails muss ich die Anhänge strukturiert in Ordnern ablegen. Dafür habe ich nachstehendes Script für die Ablage von E-Mail Anhängen in nach Datum sortierten Ordnern, welches aber nicht funktioniert. Dass Script ist als Ausführung bei einer Mail-Regel aktiviert. Mail hat vollen Festplattenzugriff, der Ordner Mail-Anhänge ist vorhanden. Was passt noch nicht?
using terms from application "Mail"
on perform mail action with messages theMessages for rule theRule
set baseFolder to (path to documents folder rule type alias)
tell application "Mail"
repeat with theMessage in theMessages
set msgDate to short date string of (date sent of theMessage)
-- Folder-Namen anpassen: z.B. 12.09.2025
set saveFolder to (baseFolder as string) & "Mail-Anhänge:" & msgDate & ":"
tell application "Finder"
if not (exists folder saveFolder) then
make new folder at folder (baseFolder as alias) with properties {name:msgDate}
end if
end tell
repeat with theAttachment in mail attachments of theMessage
set attachmentName to name of theAttachment
set savePath to saveFolder & attachmentName
try
save theAttachment in file savePath
end try
end repeat
end repeat
end tell
end perform mail action with messages
end using terms from