/ Published in: Ruby
Expand |
Embed | Plain Text
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
Comments
Subscribe to comments
You need to login to post a comment.

1.require "appscript"2.include Appscript3. 4.def sendemail(subject, content, *addresses)5. mail = app('Mail')6. 7. msg = mail.outgoingmessages.end.make(:new => :outgoingmessage)8. 9. # mail.set(msg.visible, :to => true) # by default, 10. mail.set(msg.subject, :to => subject)11. mail.set(msg.content, :to => content)12. # mail.set(msg.sender, :to => "[email protected]") # otherwise default email address used13. 14. addresses.each do |addr|15. msg.torecipients.end.make(:new => :torecipient, :withproperties => {:address => addr})16. end17. 18. msg.send_ 19.end20. 21.# send_email("subject goes here", "Hello Cruel