1

我根本不知道 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 会从电子表格的一行中读取姓名和电子邮件地址,然后使用标准的苹果邮件程序发送这封电子邮件,填写姓名和电子邮件地址。

发送消息后,我希望脚本等待 60 秒。然后发送另一封电子邮件。

这需要在遇到空白行之前发生。

我的第一个问题……这可能吗?如果可能的话,我该怎么做?

还有更好的方法来做我想做的事情吗?

谢谢

4

2 回答 2

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
于 2013-03-13T14:01:22.850 回答
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
于 2013-03-13T16:05:37.150 回答