Find Recently Flagged Messages in Mail.app with appscript


/ Published in: Ruby
Save to your folder(s)



Copy this code and paste it in your HTML
  1. #!/usr/bin/env ruby
  2.  
  3. require "rubygems"
  4. require "appscript"
  5. include Appscript
  6. require "active_support"
  7.  
  8. mail = app("Mail")
  9.  
  10. accounts = {"Personal" => "INBOX",
  11. "Both Pieces IMAP" => "INBOX",
  12. "Exchange" => "INBOX"}
  13.  
  14. accounts.each do |acct,box|
  15.  
  16. account = mail.accounts[acct].get
  17. inbox = account.mailboxes[box].get
  18. messages = inbox.messages[its.flagged_status.eq(true).and(
  19. its.date_received.gt(Time.now - 3.days)
  20. )].get
  21.  
  22. messages.each do |m|
  23. puts m.subject.get
  24. end
  25.  
  26. end
  27.  
  28.  

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.