Originally Posted by Ragnorok
- Impossible. Roit. (sigh)
- Never thought of screen scraping, actually, but it may be acceptable to just use the "Send with vodoo" button. I'll run that by The Powers That Be and see what they have to say about that.
- But I'm still intrigued. Could you give an overview of how you do screen scraping on a RIM unit? Just as a fallback in case the "Send with vodoo" menu option isn't acceptable.
- BTW, we're running v4 on all units for this project, so I shouldn't have to worry about the context. Shouldn't, I say. (wink)
- I know of no way to "overload" an existing application's menu option. It will simply add another "Send", leading to confusion for the poor user. At least that's what I *think* will happen; I asked RIM about doing just that and got a negative response.
- Thanks for your time...
There isn't a way to overload a built in menu, I would assume. RIM wouldn't take too kindly to that.
Adding your own menu entry to the email application is pretty easy though, and you can specify whether to show in compose or view individually. This is the *only* option for what you want. You cannot get your code to run when the user clicks "Send". It is just not possible. If the suits tell you to make your code run when the user clicks "Send" instead of your own custom menu entry, tell them to call RIM. Hell, you can't even do this in other email clients, like Outlook or Notes, IIRC, and neither would you want to. It is not a good idea to pull the rug out from under the user and make things not work the way they expect. Also, if your code breaks, the end-user might very well call RIM, and then they'll be po'ed at you.
In short, it is impossible. RIM designed the thing to be "unhackable" or whatever, so that means you can't change the plumbing of the thing very much.
Since you're running on all OS4 devices, don't worry about screenscraping too much. One thing to watch out for is replies and forwards though... because the device uses CMIME, the original message block *isn't* part of the body text. (CMIME only sends the ID of the message to include as an original message) Thus, you need to screen scrape that.
Screen scraping is pretty painful, and it can't be very good for performance... but I have to make do. I've gotten my routines down to an art, but I can't share. Some hints though:
Get the current screen object by calling net.rim.device.api.ui.UiApplication.getActiveScree n. Screen IS_A Manager, so you can get a field count and go through each field on the screen. The to, cc, and bcc fields are a subclass of HorizontalFieldManager, the subject is a LabelField (I think), the body is an autotext edit field and can be detected because it is preceded by a SeparatorField (and there can be more than one body field...), the Original Messages block is a VerticalFieldManager, and attachments are shown after another separator field.
The VFM has label fields, edit fields, and datefields.
The debugger is most helpful in this. Make a basic application, and get the current screen object. Just go through the hierarchy of objects in the screen.
Yes, I know quite a lot about this stuff. Because I've spent hours going through the debugger to find what I want.