如何将文件附加到Apple Mail撰写窗口?

时间:2019-01-07 09:34:56

标签: macos applescript

我能够创建一个新的外发消息,然后将文件附加到该消息,但无法附加到已经打开的撰写窗口,如何将钩子链接到已打开的撰写窗口,然后附加文件。下面是我用来通过创建新的撰写窗口来附加文件的代码

 set userName to short user name of (system info)
 set theAttachmentFolder to "/Users/" & userName & "/Documents/Test/" as POSIX file as alias
 tell application "Finder" to set attchList to get every file of folder (theAttachmentFolder)

 tell application "Mail"
 set msg to make new outgoing message with properties{visible:true}
 tell msg
    repeat with attach in attchList

    make new attachment with properties {file name:(contents of attach as alias)}
 end repeat

 end tell

 end tell 

0 个答案:

没有答案