Sto provando a creare un applescript che accetta i messaggi che corrispondono a un determinato filtro YYYY) e li inoltra a un taccuino specifico in Evernote (XXXX), con l'allegato intatto. Finora, ho ottenuto questo script per gestire l'inoltro ad un taccuino Evernote, ma non riesco a capire come gestire correttamente gli allegati.
Come faccio ad allegare tutti gli allegati nelle e-mail trovate dal filtro (che idealmente dovrebbe essere eseguito quando i messaggi vengono ricevuti) alla nuova e-mail inoltrata?
using terms from application "Mail"
on perform mail action with messages selection for rule YYYY
tell application "Mail"
set theSelection to selection
set thesubject to subject of item 1 of theSelection
set theAttachments to every attachment of content of theSelection
set theForwardedMessage to forward (item 1 of theSelection) with opening window
tell theForwardedMessage
make new to recipient at end of to recipients with properties {address:"ZZZZ"}
set subject to subject of item 1 of theSelection & " @XXXX"
repeat with a from 1 to length of theAttachments
log "message_attachment =" & a
make new attacment with properties {filename:a} at after last paragraph
end repeat
send
end tell
end tell
end perform mail action with messages
end using terms from