Guest User

Untitled

a guest
Mar 7th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.92 KB | None | 0 0
  1. require 'rubygems'
  2. require 'rbosa'
  3. require 'tmail'
  4. require 'net/pop'
  5.  
  6. opts = {:username => '[ur pop box]', :password => '[ur pw!]', :server => '[ur server]'}
  7.  
  8.  
  9. pop = Net::POP3.new(opts[:server])
  10. pop.start(opts[:username], opts[:password])
  11. things = OSA.app('Things')
  12. inbox = things.lists.collect {|i| i if i.name.match /Inbox/ }.delete_if {|i| i.nil? }.first
  13.  
  14. def remove_sig (str)
  15. if str.match /--\n/
  16. str.split("-- ").first
  17. else
  18. str
  19. end
  20. end
  21.  
  22. if pop.mails.empty?
  23. exit
  24. else
  25. pop.each_mail do |mail|
  26. message = TMail::Mail.parse(mail.pop())
  27. message_body = remove_sig(message.body)
  28. todo = Hash.new
  29. if message.subject.size != 0
  30. todo[:name] = message.subject.strip
  31. if message_body.strip.size != 0
  32. todo[:note] = message_body.strip
  33. end
  34. elsif message_body.strip.size != 0
  35. todo[:name] = message_body.strip
  36. end
  37. things.make(OSA::Things::ToDo, inbox, todo)
  38. mail.delete
  39. end
  40. end
Add Comment
Please, Sign In to add comment