Hallo Goar,
ich habe eine Lösung gebaut, mit der ich sehr gut klar komme.
Du kannst es dir ja mal anschauen.
--Das aktuelle Tagesdatum erstellen
set {year:y, month:m, day:d} to (current date)
set theDate to d & "-" & m & "-" & y as string
--Den Speicherort für Mailanhänge
set theOutputFolder to "Macintosh HD:Users:myUser:Desktop:mailAttache:"
set folderCheck to theOutputFolder & theDate
tell application "Finder"
-- prüfen, ob für den heutigen Tag schon ein Ordner existiert
if exists folderCheck then
-- Bedingung "Folder existiert"
-- Email Eingang auf neue Mails checken, die Status ungelesen haben.
-- Mailanhänge werden in den heutigen Ordner kopiert
tell application "Mail"
check for new mail
set unreadMessages to (messages of inbox whose read status is false)
set newOrder to number of items in unreadMessages
if newOrder > 0 then
repeat with eachMessage in unreadMessages
try
repeat with a in (every mail attachment of eachMessage)
set documentName to name of a
if (documentName contains ".pdf") then
set savePath to folderCheck & ":" & documentName
save a in file (savePath)
end if
end repeat
end try
set read status of eachMessage to true
end repeat
end if
end tell
else
-- Bedingung Folder existiert nicht. Neuer Ordner mit Tagesdatum wird angelegt.
make new folder at theOutputFolder with properties {name:theDate}
set newFolder to theOutputFolder & theDate & ":"
tell application "Mail"
check for new mail
set unreadMessages to (messages of inbox whose read status is false)
set newOrder to number of items in unreadMessages
if newOrder > 0 then
repeat with eachMessage in unreadMessages
try
repeat with a in (every mail attachment of eachMessage)
set documentName to name of a
if (documentName contains ".pdf") then
set savePath to newFolder & documentName
save a in file (savePath)
end if
end repeat
end try
set read status of eachMessage to true
end repeat
end if
end tell
end if
end tell
Das Script schreibt mir brav die Mails in einen Ordner.
Jetzt müsste ich die PDF's noch ausdrucken und fertig ist.
Hast du vielleicht einen Tipp, wie ich die PDF am Besten ausdrucke mit Applescript?
Viele Grüße,
mcrudi