2013-03-13 55 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

相關問題