Используйте скрипт Apple для отправки электронной почты и прикрепления вложений в соответствии с названием каждого файла. - PullRequest
0 голосов
/ 17 октября 2018

У меня есть pdf файлы в папке на моем Mac.Каждый файл содержит имя контакта, зарегистрированного в моей адресной книге.например:

  • Student_DUMONT Brux_10_16_2018__15_54_test.pdf
  • Student_ZEORI Sophie_10_16_2018__15_54_test.pdf
  • и т. д.

я могу найтиработать, но я не могу сделать необходимые приспособления для его работы.Пожалуйста, помогите мне

set theSubject to "Sujet"
set theBody to "Hello, this is your work"
set theAddress to "student_email@gmail.com"
set theSender to "Some Sender"
set theAttachment to "Macintosh HD:Users:UserName:Desktop:Student_DUMONT Brux_10_16_2018__15_54_test.pdf"

tell application "Mail"


set theNewMessage to make new outgoing message with properties {subject:theSubject, content:theBody & return & return, visible:true}


tell theNewMessage


set visibile to true


set sender to theSender
        make new to recipient at end of to recipients with properties {address:theAddress}
    try
        make new attachment with properties {file name:theAttachment} at after the last word of the last paragraph
        set message_attachment to 0
    on error errmess -- oops
        log errmess -- log the error
        set message_attachment to 1
    end try
    log "message_attachment = " & message_attachment
    #send
end tell
end tell
...