2013-03-13 53 views
0

我根本不知道AppleScript,所以在此先感谢您提供有关此问题的任何帮助。 我在安装了最新版OSX的Macbook Pro笔记本电脑上。我有一个Excel电子表格(我可以使用数字,如果这使得它更容易)与两列。用于从Excel中的列表发送电子邮件的AppleScript

FirstName  Email 
------------  ----------------- 
Ken    [email protected] 
Mike    [email protected] 

这是我的客户名单,我想给他们发一封电子邮件。不幸的是,我没有这个自动回复列表,所以我必须逐一发送邮件。

我知道我可以掀起一个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秒。然后发送另一封邮件。

这需要发生,直到遇到一个空行。

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

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

感谢

+0

我可以把数据在.csv格式。 – codingguy3000

回答

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 
2

有可能是一个更好的方式来做到这一点,但不能你刚才的地址复制为TSV或CSV?

set addresses to "Ken;[email protected] 
Mike;[email protected]" 
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 
+0

有关使用CSV格式的重要提示。我可以做到这一点。 – codingguy3000

相关问题