Busy looping for an hour would be really bad. I assume you would have a sleep 
in there, but then you're still polling.

If you are using MacRuby, looking at the GCD API would be a good idea. You 
could do something like this:

def schedule_email q
    q.after(3600) do
        # Send email
        schedule_email q
    end
end

schedule_email Dispatch::Queue.new("com.rosson.delayed.email")

NSRunLoop.currentRunLoop.run



As for actually sending emails, if you want to have things go through Apple 
Mail you could use the ScriptingBridge framework which has a few tutorials 
online (but for iTunes):

http://arstechnica.com/apple/2011/09/tutorial-os-x-automation-with-macruby-and-the-scripting-bridge/

AXElements is another option that I am biased in favour of; but it may not be 
passive enough for your requirements.

HTH,
        Mark


On 2012-10-19, at 6:12 PM, Cliff Rosson <cliff.ros...@gmail.com> wrote:

> Hi Everyone,
> 
> I am fairly new to macruby and am having trouble finding some basic 
> documentation to help me out. I would like to write a simple app that sends a 
> delayed email based on Time from mac mail.
> 
> I am thinking of something like this,
> 
> time = Time.now + 3600
> while true
>   case time
>   when Time.now
>     #Send email
>   end
> end
> 
> Being able to respond to certain emails or send an email from a draft would 
> be a huge benefit. Can anyone point me in the write direction to accomplish 
> this? I am decently proficient in ruby but don't know where to start with 
> MacRuby.
> 
> Thanks everyone
> 
> _______________________________________________
> MacRuby-devel mailing list
> MacRuby-devel@lists.macosforge.org
> http://lists.macosforge.org/mailman/listinfo/macruby-devel

_______________________________________________
MacRuby-devel mailing list
MacRuby-devel@lists.macosforge.org
http://lists.macosforge.org/mailman/listinfo/macruby-devel

Reply via email to