is it possible that when a new email message is received to run applescript to copy sender’s email address to clipboard and paste it to next empty cell in column e in numbers, I've been trying with this, but it doesn't select the first message
thanks in advance :)
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
It is best not to use UI scripting here. You want to set this up as a trigger in mail.app. Your script can pull the sender email address and then programmatically add it to the first empty cell in a row. Here's a script to get you started:
Edit: I edited the script to check for the next cell with a 'missing value' (instead of the cell value > 0) so that it can handle numbers and dates, such as: set value of cell r to date "12/5/15"