我完全不懂AppleScript,所以提前感谢您提供有关此问题的任何帮助。 我在我的Macbook Pro笔记本电脑上安装了最新版本的OSX。我有一个Excel电子表格(我可以使用数字,如果这样更容易),有两列。
FirstName Email
------------ -----------------
Ken blah@blah.com
Mike blahblah@blahblah.com
这是我的客户列表,我想向他们发送电子邮件。不幸的是我在自动回复器中没有这个列表所以我必须逐个发送电子邮件。
我知道我可以发送一个PHP脚本来发送电子邮件,但是这样做时,电子邮件的可传递性存在问题。
我想编写一个AppleScript,一次处理一行电子表格并发送消息。 消息将是这样的:
Subject: How’s it going?
Hi Ken
It’s been a while since I sold you that defective widget from China.
If you need more defective elctronics I’m here for you. Just give me
a call at xxx-xxx-xxxx.
Sincerely
Ken
AppleScript将从电子表格的一行读取姓名和电子邮件地址,并使用标准的Apple邮件程序发送此电子邮件,填写姓名和电子邮件地址。
发送消息后,我希望脚本等待60秒。然后发送另一封邮件。
这需要在遇到空白行之前发生。
我的第一个问题......这可能吗?如果可能,我该怎么办?
还有更好的方法来做我想做的事情吗?
谢谢
答案 0 :(得分:2)
可能有更好的方法,但你不能只将地址复制为TSV或CSV吗?
set addresses to "Ken;blah@blah.com
Mike;blahblah@blahblah.com"
set text item delimiters to ";"
repeat with l in paragraphs of addresses
tell application "Mail"
tell (make new outgoing message)
set subject to "subject"
set content to "Hi " & text item 1 of l & linefeed & linefeed & "..."
make new to recipient at end of to recipients with properties {name:text item 1 of l, address:text item 2 of l}
send
delay (random number) * 100
end tell
end tell
end repeat
答案 1 :(得分:1)
尝试:
set {firstName, eAddress} to getData()
repeat with i from 1 to count firstName
tell application "Mail"
activate
set mymail to make new outgoing message at the beginning of outgoing messages with properties {subject:"How’s it going?"}
tell mymail
make new to recipient at beginning of to recipients with properties {address:item i of eAddress}
set content to "Hi " & item i of firstName & "
It’s been a while since I sold you that defective widget from China.
If you need more defective elctronics I’m here for you. Just give me
a call at xxx-xxx-xxxx.
Sincerely
Ken"
end tell
--show message window (otherwise it's hidden)
set visible of mymail to true
--bring Mail to front
activate
send mymail
end tell
end repeat
on getData()
set colA to {}
set colB to {}
tell application "Microsoft Excel"
activate
tell active sheet
set lastRow to first row index of (get end (last cell of column 1) direction toward the top)
repeat with i from 3 to lastRow
set end of colA to (value of range ("A" & i))
set end of colB to (value of range ("B" & i))
end repeat
end tell
end tell
return {colA, colB}
end getData