Hi Cliff, Did you manage to find the SBSendEmail sample code:
https://developer.apple.com/library/mac/#samplecode/SBSendEmail/Introduction/Intro.html The sample they have looks a bit different from what you have. I haven't tried it out myself, but their documentation seems quite thorough and was updated only a year ago. On 2012-10-23, at 5:28 AM, Steve Clarke <st...@sclarkes.me.uk> wrote: > Just had a closer look at what I did with sending mail and I think my earlier > reply was probably wrong, or at least not helpful. I think the difficulty > arises because there are some things that ScriptingBridge is unable to do. I > could not find a way to create an outgoing message with ScriptingBridge and I > had to resort to running a trivial applescript (using NSAppleScript > executeAndReturnError) to do the job for me. If anyone knows a better way > I'd be delighted to hear about it! > > I created the applescript from a template that I modified in my code before I > executed it. I guess Cliff could adopt a similar approach to copy subject, > content etc from his draft. > > Here's the template. The %HTML% and %SUBJECT% are placeholders that get > replaced by the actual values before execution. > > ========================= > tell application "Mail" > activate > set htmlMsg to "%HTML%" > set subjecta to "%SUBJECT%" > set theMsg to make new outgoing message with properties ¬ > {subject:subjecta, html content:htmlMsg & return & return, > content:""} > end tell > ========================= > > Steve > > On 23 Oct 2012, at 07:06, Cliff Rosson <cliff.ros...@gmail.com> wrote: > >> So playing around a little with this I was able to browse and find messages >> via macruby. On the other hand I cannot figure out how to send a drafted >> email. Here is what I have so far. >> >> My drafts folder has 1 message in it ready to be sent. >> >> mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail") >> my_account = mail.accounts.select { |account| account.name == >> "MyAccountName" }.first >> drafts_folder = my_account.mailboxes.select { |mailbox| mailbox.name == >> "Drafts" }.first >> draft = drafts_folder.messages.first >> >> I need to use the send method somehow. I think I need to make a new >> MailOutgoingMessage but I would like to make this message based on my >> already existing draft message. >> >> Any know how this is done? >> >> I had hoped it would have been as simple as draft.send. :) >> >> >> On Sat, Oct 20, 2012 at 2:14 PM, Mark Rada <mr...@marketcircle.com> wrote: >> Hi Rob, >> >> I think Colin answered this fairly well. Personally, I prefer to use GCD >> when available because I find the API simpler and GCD stuff works with or >> without run loops. >> >> -- >> Mark >> >> >> On 2012-10-20, at 2:40 PM, Robert Carl Rice <rice.au...@pobox.com> wrote: >> >> > Hi Mark, >> > >> > I use NSTimer a lot in my apps. What is the advantage of using GCD API? >> > >> > There is an excellent tutorial on the web for specifically for setting up >> > ScriptingBridge for Apple Mail but I forget where I saw it. On warning; if >> > you set up ScriptingBridge for Apple Mail don't try to take a snapshot in >> > Xcode 4. Xcode will follow the link to mail and include all of your >> > mailboxes in the snapshot. I don't know if there is a way to stop this >> > behavior. >> > >> > Bob Rice >> > >> > On Oct 19, 2012, at 6:50 PM, Mark Rada <mr...@marketcircle.com> wrote: >> > >> >> 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 >> >> >> > >> > _______________________________________________ >> > 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 >> >> >> >> -- >> http://about.me/cliffrosson >> vizualize.me/cliffrosson >> _______________________________________________ >> 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
_______________________________________________ MacRuby-devel mailing list MacRuby-devel@lists.macosforge.org http://lists.macosforge.org/mailman/listinfo/macruby-devel