尝试为每个地址发送带有特定附件的多封邮件。每个地址都有自己的附件子文件夹。 “抓住附件部分”不起作用,我不确定处理程序是否设置正确:我应该将子文件夹传递给处理程序内的邮件,还是保留它。这是我的第一个长脚本,所以请不要太苛刻; - )
我认为我更接近工作解决方案,我仍然没有让它发挥作用。到目前为止,这是我的脚本:
` with timeout of 600 seconds
-- Liste: Alle Empfänger
tell application "Contacts"
set emailList to {}
set testPersons to every person of group "Test"
repeat with thisTestPerson in testPersons
set end of emailList to (value of email of thisTestPerson) as string
end repeat
end tell
-- Liste fuer die Übergabe alphabetisch sortieren
set the_list to emailList
set otid to AppleScript's text item delimiters
set AppleScript's text item delimiters to {ASCII character 10} -- always a linefeed
set list_string to (the_list as string)
set new_string to do shell script "echo " & quoted form of list_string & " | sort -f"
set new_list to (paragraphs of new_string)
set AppleScript's text item delimiters to otid
-- Liste: Alle Subfolder
tell application "Finder"
set mainfolder to choose folder "select a folder"
set folderList to {}
set myFolders to every folder of mainfolder
repeat with attachFolder from 1 to (count of myFolders)
set end of folderList to attachFolder as string
end repeat
end tell
-- Sicherheits-Check
set count1 to count of myFolders
set count2 to count of new_list
if count1 is not equal to count2 then
display dialog "Houston, we have a problem:" & return & "Die beiden Listen sind nicht gleich lang..." buttons {"ok"} with icon 2
return
end if
end timeout
--handler processfolder(myFiles)
on processfolder(myFiles)
tell application "Mail"
activate
set theAddress to (item i of emailList)
set theMex to (make new outgoing message at end of outgoing messages with properties {visible:true, subject:"Subjectheader", content:"email body"})
tell content of theMex
make new attachment with properties {file name:FileList} at after last paragraph
end tell
tell theMex
make new to recipient at end of to recipients with properties {address:theAddress}
end tell
send theMex
end tell
end processfolder
-- grab attachments and send mail
tell application "Finder"
repeat with myFolder from 1 to (count of folderList)
set FileList to {}
set myFiles to entire contents of myFolder
repeat with thisFile in myFiles
set end of FileList to thisFile as string
end repeat
my processfolder(myFiles)
end repeat
end tell
display dialog (count1 as string) & " Nachrichten verschickt."
end`
我相信处理程序应该正常工作。将子文件夹列表与地址列表匹配似乎仍然是一个问题,我不确定我的重复循环“抓住附件和发送邮件”是否有效。这是一个棘手的重复循环使用,我仍然在努力。关于我还在做错什么的快速想法?
感谢您的帮助!我真的很感激! 马可
答案 0 :(得分:1)
您必须将变量作为参数传递给处理程序:
1- (item i of emailList)
: i 和 emailList 未在处理程序中定义。
2- {file name:FileList}
:文件列表未在处理程序中定义,文件名必须是alias
或{{1}类型的路径},而不是路径列表。
string
: myfolder 变量是set myFiles to entire contents of myFolder
,integer
将包含文件夹和文件,如果文件夹不包含子文件夹,{{ 1}}没用,请使用entire contents
。
其余的都没问题,但包含不必要的行。
这是脚本:
entire contents
答案 1 :(得分:0)
它完成了!感谢您和一两个其他专业人士,我现在有一个漂亮的批量邮件脚本例程,使用automator,bash行和(主要)applescript。我将它用于工作申请,但您可以将它用于任何需要使用Mail,MS Word和Excel中任何给定的联系人列表(或者地址簿)进行个性化批量发送电子邮件的情况。为了完成,我将添加所有必要的步骤。任何给定的x名称列表,电子邮件地址,个人地址,您可以生成x子文件夹,包含x个性化字母和非个性化文档(谢谢,杰克!添加文档完美地工作)。一旦你开始最后一个脚本并选择文件夹,你就可以看到邮件全部发送出来,通过名字对这个人说话并附上正确的个性化信件!它更正了在电子邮件地址中以不同方式呈现的外来名称拼写。它最适合使用“@”之前的姓氏的电子邮件地址,现在可以忽略名字,如果它在姓氏前面设置(即firstname.lastname@company.com)。非常感谢大家的帮助!这是伟大的团队努力。 我将在家时立即发布,如果我在此处和其他相关问题中发布,或者是否有共享论坛?