2015-07-20 58 views
0

我試圖通過郵件應用程序發送附件,並且在源文本文件中有沒有擴展名的文件名列表。每行將循環直到文本文件中的所有行完成。郵件附件的Applescript變量路徑

如何使用源文本的循環線爲附件創建路徑並將擴展添加到最後?

這是我用什麼來讀取文本文件和循環他們

set lns to paragraphs of (read file srcFile as «class utf8») 
repeat with ln in lns 

線這是劇本的發送附件部分看

set theAttachmentFile to "Macintosh HD:Users:attachmentfolder" + ln + ".pdf" 

以上不工作。

謝謝!

回答

0

如果您的文本文件只包含沒有路徑和擴展名的文件名,我假設這些文件的存儲路徑在腳本中是已知的:正確嗎?

關於擴展,將其存儲在文本文件中更容易出於兩個原因:如果不這樣做,則需要獲取名稱包含「xxx」的每個文件,然後交叉手指,找到一個只有一個文件。如果有兩個文件的標題相同但擴展名不同,則不能選擇!

用於創建新的電子郵件和添加附件的腳本應該是:

Tell Application "Mail" 
Set newMessage to make new outgoing message with properties {visible:true, subject:My_Subject, content:My_Content} 
tell newMessage 
    make new to recipient at end of to recipients with properties {name:"", address:send_to_addr} 
    make new attachment with properties {file name:TheAttachmentFile} at after the last paragraph 
end tell 
end tell