【发布时间】:2015-11-17 04:15:29
【问题描述】:
我在 Macbook Pro 上运行 Apple OS X 10.11.1。我使用 OpenOffice Calc ver 4.1.2 Macros 从 Internet 下载 SQL 数据,对数据进行计算,然后创建结果的 pdf 文件,然后发送给人们。 OpenOffice Basic 中内置的电子邮件例程在运行 Windows 7 的 PC 上运行良好,但在 Mac 上,收件人和主题字段不会传递到 Mac Mail.app。为了解决这个问题,我测试了文件路径是以 PC 为中心还是以 Mac 为中心,如果是以 Mac 为中心,我创建一个文本文件,其中包含所有 pdf 文件的 Mac 中心路径,然后调用读取文本的 Applescript文件数据,添加主题行和收件人 EM 地址,将 pdf 文件附加到电子邮件中,然后将电子邮件发送给收件人,无需用户干预。如果脚本在桌面或 Documents 文件夹中,它可以正常工作,但如果它放在我的 Dropbox 文件夹中则不行。我收到“网络文件权限错误。(-5000)。我试图通过转到 Dropbox 首选项来修复文件权限,按住选项键并单击“修复权限”按钮,但这也不起作用。
谁能告诉我该怎么做才能解决这个问题。我已经包含了 Applescript 和文本文件,所以你可以看到会发生什么。
on run
(* tell application "Finder"
open file "somefile.txt" of folder of (file (path to me))
end tell *)
set myPath to (path to me) as text
set MME_path to POSIX path of myPath
set b to MME_path
set text item delimiters to "/"
set d to {}
set c to text items of b
set myhome to item 3 of c
-- display dialog MME_path & " " & myhome
set myPrefsFile to item 2 of c & "/" & item 3 of c & "/" & item 4 of c & "/" & item 5 of c & "/EM-Eargv.txt"
open for access myPrefsFile
set PrefsContents to read myPrefsFile using delimiter {","}
close access myPrefsFile
set thesubject to item 1 of PrefsContents
set thebody to ""
set theSender to item 2 of PrefsContents
set theAddress to item 3 of PrefsContents
set theAttachment to item 4 of PrefsContents
set theAttachment1 to POSIX file theAttachment
set theAttachment to item 5 of PrefsContents
set theAttachment2 to POSIX file theAttachment
set theAttachment to item 6 of PrefsContents
set theAttachment3 to POSIX file theAttachment
set theAttachment to item 7 of PrefsContents
set theAttachment4 to POSIX file theAttachment
--set userCanceled to false
--try
-- set dialogResult to display dialog ¬
-- "Path to file is " & theAttachment & " POSIX " & theAttachment1 buttons {"Cancel", "OK"} ¬
-- default button "OK" cancel button ¬
-- "Cancel" giving up after 15 ¬
-- default answer (long user name of (system info))
--on error number -128
-- set userCanceled to true
--end try
tell application "Mail"
set newMessage to make new outgoing message with properties {subject:thesubject, content:thebody}
tell newMessage
set visible to true
set sender to theSender
make new to recipient at end of to recipients with properties {name:theSender, address:theAddress}
tell content
make new attachment with properties {file name:theAttachment1} at after the last paragraph
make new attachment with properties {file name:theAttachment2} at after the last paragraph
make new attachment with properties {file name:theAttachment3} at after the last paragraph
make new attachment with properties {file name:theAttachment4} at after the last paragraph
end tell
end tell
delay 3
send newMessage
end tell
delay 3
(*
tell application "Mail"
quit
end tell
*)
end run
文本文件名为 EM-Eargv.txt
EM-Docs Files FYI.,”Your Name”,”YourEMaddress”,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc1.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc2.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc3.pdf,file:///Users/admin/Documents/Dropbox/EM-Docs/Sends/Doc4.pdf,
您必须使用您自己的姓名和电子邮件地址更新此文本文件,并将路径更改为您的任何内容,并在其中放置 4 个名为 Doc1.pdf、Doc2.pdf、Doc3.pdf 和 Doc4.pdf 的短 PDF 文件一个名为“发送”的文件夹,在这个小程序将电子邮件发送给您之前。
我可以向您发送一个简短的 OpenOffice Calc 文档,该文档会为您的计算机配置创建包含正确路径文件数据的文本文件,但我不知道如何将 Calc.ods 文件附加到此请求中。
我从名为“EM-Docs”的目录中运行整个示例,我可以创建一个要下载的 Zip 文件,但同样,我看不到将 zip 文件附加到此请求的方法。
【问题讨论】:
-
脚本是否保存在您的 Dropbox 文件夹中(如您所说),或者文本文件 EM-Eargv.txt 是否保存在您的 Dropbox 文件夹中是问题所在,因为这对我来说更有意义.
标签: applescript osx-mavericks email-attachments