Sono un principiante con applescript. Sono riuscito a mettere insieme un piccolo script che aggiunge file selezionati dal finder a un allegato di posta elettronica come un flusso di lavoro di servizio. Ora ho bloccato l'ultimo numero. Mi piacerebbe aggiungere il nome del file all'oggetto. Ecco il applescript. Qualcuno potrebbe aiutare?
property mailSubjectPrefix : "Datei(en) für dich: "
property subjAttNameSeparator : ", "
property attachSeparator : "*******"
property attachPrefix : "Anhänge:"
set theSubject to "Datei(en): "
set theContent to "Datei(en) für dich:"
set recipientAddress to {}
tell application "Contacts"
set recipientAddress to "[email protected]"
end tell
tell application "Finder"
-- Make a list to gather the names of the selected files
set fileAliases to {}
-- Get the selection of the frontmost Finder window
set fileSelection to the selection
-- Iterate of the selection
repeat with fileItem in fileSelection
copy the fileItem as alias to the end of fileAliases
end repeat
-- Check if the selection is not empty
if the number of items of fileAliases is 0 then
-- Audible feedback, so the script always does something.
beep
else
-- Now talk to mail to create the message
tell application "Mail"
set newMessage to make new outgoing message at beginning with properties { content:theContent, visible:true}
set mailSubject to {}
-- Set a recipient
tell newMessage
make new to recipient at end with properties {address:recipientAddress}
set MailSubject to fileAliases
set oTID to AppleScript's text item delimiters
set AppleScript's text item delimiters to subjAttNameSeparator
set subject to mailSubjectPrefix & (mailSubject as string)
set AppleScript's text item delimiters to oTID
end tell
-- Attach all the selected files
repeat with fileAlias in fileAliases
make new attachment with properties {file name:fileAlias} at after the last paragraph of newMessage
end repeat
-- Put Mail in the foreground
activate
end tell
end if
end tell