Return to Snippet

Revision: 2669
at March 22, 2007 21:20 by bbebop


Initial Code
require "appscript"
include Appscript

def send_email(subject, content, *addresses)
  mail = app('Mail')

  msg = mail.outgoing_messages.end.make(:new => :outgoing_message)

  # mail.set(msg.visible, :to => true)  # by default, 
  mail.set(msg.subject, :to => subject)
  mail.set(msg.content, :to => content)
  # mail.set(msg.sender, :to => "[email protected]")  # otherwise default email address used

  addresses.each do |addr|
    msg.to_recipients.end.make(:new => :to_recipient, :with_properties => {:address => addr})
  end

  msg.send_  
end

# send_email("subject goes here", "Hello Cruel World!", "[email protected]") # => true

Initial URL


Initial Description


Initial Title
Sending Apple Mail with Ruby and rb-appscript instead of Applescript

Initial Tags
ruby

Initial Language
Ruby