2016-05-03 71 views
0

我不熟悉腳本,並且正在嘗試爲郵件編寫簡單的腳本。我需要發件人地址,或者我們可以說發件人地址。但我沒有從中得到任何東西。我的腳本如下。從蘋果的郵件得到「發件人」或發件人地址

tell application "Mail" 
    try 
     set theSelectedMessage to selection 
     set msgCount to count of theSelectedMessage 
     if (msgCount = 1) then 
      set theMsg to item 1 of theSelectedMessage 
      #also tried this 
      #set theSender to extract name from sender of theMsg 
      set theSender to (sender of theMsg) 
      display dialog "name:" & theSender 
     end if 
    end try 
end tell 

Dialog即將到來,但沒有發件人的詳細信息。

回答

0

天上
我忘了我實現的,我面臨的問題郵件帳戶的原因。
郵件>首選項>帳戶>帳戶信息>啓用此帳戶

0

基本上extract name from纔是正道

tell application "Mail" 
    set selectedMessages to selection 
    if selectedMessages = {} then return 

    repeat with aMessage in selectedMessages 
     set senderName to extract name from sender of aMessage 
     set senderAddress to extract address from sender of aMessage 
     display dialog " name: " & senderName & return & "address: " & senderAddress 
    end repeat 
end tell 
+0

我添加到我的問題在評論....不工作,... –

+0

此代碼應該工作。我測試成功了。 – vadian

相關問題