2016-05-03 32 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

相关问题