Re A) I think it should be easy to transfer the content from draft to outgoing message. Don't both use MailRichText?
B) I think you'll be stuck with that problem. As far as I can see you can't mutate an existing message into an outgoing message. Steve On 23 Oct 2012, at 19:05, Cliff Rosson <cliff.ros...@gmail.com> wrote: > Yea putsing methods(true,true).sort is pretty useful. Below is what I have > compiled so far. > > framework "ScriptingBridge" > > @mail = SBApplication.applicationWithBundleIdentifier("com.apple.mail") > @my_account = @mail.accounts.select { |account| account.name == "MyAccount" > }.first > @drafts_folder = @my_account.mailboxes.select { |mailbox| mailbox.name == > "Drafts" }.first > @draft = @drafts_folder.messages.first > > def send_message(message) > props = {} > > props['subject'] = message.subject > props['sender'] = message.sender > #props['content'] = message.content > > > outgoing_msg = @mail.classForScriptingClass('outgoing > message').alloc.initWithProperties(props) > @mail.outgoingMessages.addObject(outgoing_msg) > recipient = @mail.classForScriptingClass('to > recipient').alloc.initWithProperties({'address'=>message.recipients.first.address}) > outgoing_msg.toRecipients.addObject(recipient) > > outgoing_msg.send > > end > send_message(@draft) > > *Note I used instance variables so I could play with these objects in macirb. > If you were wondering... > > The code above works. I get the email. Two issues however. > > A) > I can't figure out how to pull the text contents of my @draft.contents > message. Presumably because it is a MailRichText class and not a simple > string object. If only somehow I could attach this contents to the outgoing > message to preserve the body. What would be even better is to simply create > my outgoing message with something like InitWithDraft so as to use a drafted > email already created. I suspect this will require further research from me. > > @draft.content > => <MailRichText @0x1370760: content of MailMessage 0 of MailMailbox 19 of > MailAccount 0 of application "Mail" (1845)> > > B) > The other issue is since I am not using my existing drafted email creating > this outgoing message actually makes a NEW draft in my Draft folder. It looks > like I would have to go and manually delete the draft that I am attempting to > copy in the method above. I believe there must be an easier way to do this. > This comes back to what I was talking about above by creating the outgoing > message from a draft. I guess I'll just have to do some research to figure > that out. > > Thanks Steve for your help! > > > > > On Tue, Oct 23, 2012 at 10:12 AM, Steve Clarke <st...@sclarkes.me.uk> wrote: > You need to use the ScriptingBridge documentation in Xcode - which means that > you need to spend some time understanding Objective C. I don't know it well > but enough to translate examples into Macruby. > > I found Matt Aimonetti's book very helpful when I was starting off. It > doesn't say a lot about ScriptingBridge per se, but in the end SB is just > another framework you can use from Macruby. > > It's worth looking back at the Macruby archives because Matt wrote some very > helpful stuff about using SB. One tip I recall is that you can see what > methods are available on an object in Macruby by using > obj.methods(true,true). This gives tons of stuff but critically it shows > both the Macruby methods AND the Objective C methods. With SB it's the > latter group that are of real interest. > > Steve > > On 23 Oct 2012, at 17:52, Cliff Rosson <cliff.ros...@gmail.com> wrote: > >> Perfect! How did you figure all of this out. Are there some documents that >> explain when it is appropriate to use things like "classForScriptingClass" >> etc...? >> >> On Tue, Oct 23, 2012 at 9:49 AM, Steve Clarke <st...@sclarkes.me.uk> wrote: >> >> >> >> -- >> 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 > > > > > -- > 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