applescript - 将发件人的电子邮件地址复制粘贴到数字

applescript - copy paste sender's email address to numbers

是否有可能当 运行 applescript 收到新电子邮件时将发件人的电子邮件地址复制到剪贴板并将其粘贴到数字 e 列中的下一个空单元格中,我一直在尝试这个,但它不是 select 第一条消息

提前致谢:)

property workFlowPath : quoted form of ("/Users/pl 1/Library/Application Scripts/com.apple.mail/accepted.workflow") --CHANGE THIS TO YOUR FULL WORKFLOW FILE PATH example  "/Users/pl 1/Library/Application Scripts/com.apple.mail/accepted.workflow"


using terms from application "Mail"
 on perform mail action with messages theMessages for rule theRule
  repeat with eachMessage in theMessages
   (*Get the email Subject *)
   
   set input_Argument to subject of eachMessage
   (*Run subroutine for workflow *)
   my runAutomator(input_Argument)
  end repeat
 end perform mail action with messages
end using terms from

(*Workflow  Subroutine *)
on runAutomator(input_Argument)
 
 (*Path to workflow *)
 
 
 (*Setup and Run the unix command *)
 set command to "/usr/bin/automator   -i " & quoted form of input_Argument & space & workFlowPath
 do shell script command
end runAutomator
on run {input, parameters}
 
 tell application "Numbers"
  tell application "Finder"
   set theFile to POSIX file “/Users/pl 1/Google Drive/Publication Submission Tracker2.numbers"
   open theFile
  end tell
  
 end tell
 
 return input
end run



________pause for 5 seconds______



tell application "Mail"
 reopen
 activate
 set theSenderList to {}
 set theMessages to the first message of message viewer 0
 repeat with aMessage in theMessages
  set oneAddress to extract address from sender of aMessage
  set end of theSenderList to oneAddress
 end repeat
 set the clipboard to (theSenderList as string)
end tell
return
end run

________pause for 5 seconds______



tell application "Numbers"
 reopen
 activate
 tell application "System Events" to tell process "Numbers"
  set currentCell to "e2"
  keystroke "v" using {command down}
 end tell
end tell

end run

这里最好不要使用UI脚本。您想要将其设置为 mail.app 中的触发器。您的脚本可以提取发件人电子邮件地址,然后以编程方式将其添加到一行中的第一个空单元格中。这是让您入门的脚本:

using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule

        tell application id "com.apple.iWork.Numbers"
            activate
            -- can also tell Numbers to open a specific document
        end tell

        tell application "Mail"
            repeat with eachMessage in theMessages
                set fromAddress to extract address from reply to of eachMessage

                tell application id "com.apple.iWork.Numbers"
                    tell document 1
                        tell the active sheet
                            tell table 1
                                tell column "E" -- change to preferred column
                                    -- find the last empty row in this column
                                    set r to (address of row of first cell whose value is missing value)
                                    set value of cell r to fromAddress
                                    set r to r + 1
                                end tell
                            end tell
                        end tell
                    end tell
                end tell

            end repeat
        end tell
    end perform mail action with messages
end using terms from

编辑:我编辑了脚本以检查下一个带有 'missing value' 的单元格(而不是单元格值 > 0),以便它可以处理数字和日期,例如: 将单元格 r 的值设置为日期“12/5/15”