Do you remember the olden days, when Adobe AIR and Apple’s iOS didn’t seem to play nicely, when it came to orientation?
Right. Well, that was only a few months and a couple of AIR releases ago, but since then Adobe have fixed their stuff and so we have updated our e-mail extension to reflect that.
Many of you contributed with feedback and ideas to our previous post, Native extensions for mobile AIR apps – getting round the orientation issue - thanks go to all of you! Special thanks to Nicolas Jauffret for alerting us about orientation issues with the new Adobe AIR SDKs and to Dave for letting us know that messages were not received by ActionScript!
Where’s the code?
Download the extension here: http://code.google.com/p/diadraw-air-email-native-extension-example/source/checkout
What’s new?
1. Code has been updated to work with Adobe AIR 3.4 and iOS 6.0
- Built using Adobe Flash Builder 4.6 with Adobe AIR 3.4 and XCode 4.5 with iOS SDK 6.0
- Tested on an iPhone with iOS 6
2. No more orientation mumbo-jumbo
For those of you who will build the extension from scratch, the workaround is still there, but disabled. Uncomment the following line in MailComposerDelegate.m, if you use the extension with Adobe AIR 3.2 or older:
//#import "UIViewController+Orientation.h"
For details on how and why this works, have a look at our initial post: Native extensions for mobile AIR apps – getting round the orientation issue.
3. Optional HTML in the body
The extension initially was set not to use HTML at all – thanks to Chuck for his feedback on that!
We added an optional Boolean parameter to the sendMail function, so you can set from your ActionScript whether the e-mail body will have HTML turned on or off. The parameter is optional and is TRUE by default, so even if you don’t include it explicitly, your old code should still work.
For example use of sendMail have a look at FlexApp/src/views/TestEmailAppHomeView.mxml:
m_mailExtension.sendMail ( subject, body, toRecepients, ccRecepients, bccRecepients, [attachmentStr], useHtml );
4. Bug fix: not all messages from the native side were received by the ActionScript side
… and the moral of the story was: mind your variables’ lifelines!
Looks like native code wasn’t holding on to the ExtensionContext instance for long enough, so any asynchronous messages that were sent after the mail composer was dismissed were lost.
Thanks to Dave for alerting us to the problem!
Let us know what you think
The community has been wonderful about providing feedback and alerting us to problems. Keep ‘em coming! You can post comments here or get in touch with us directly via office@diadraw.com.

Our eBook, Easy Native Extensions is out!
25% off for our mailing list subscribers
- step-by-step guide to making your iOS extension in under an hour
- example code
- single-click build scripts
- debug-ready scripts for XCode
Hi,
This is great example for native extension to send mail and good way to prevent orientation issues, I had the original mail extension code off flashsimulations.com, it was working great until I upgraded my iOS SDK to 6.0, it is throwing the below linker error, any help greatly appreciated.
ld: illegal text-relocation to ___stack_chk_guard in /Applications/XCode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS6.0.sdk/usr/lib/libSystem.B.dylib from -[MailComposerDelegate sendMail:toRecipients:ccRecipients:bccRecipients:messageBody:useHtml:attachmentsData:] in /var/folders/mg/vp5t6tx90t7gdy388cztchx00000gn/T/43a1899a-e22d-48d4-b404-833b861e9b41/libcom.commvault.NativeAPI.a(MailComposerDelegate.o) for architecture armv7
Compilation failed while executing : ld64
What does this mean exactly ? and how do I resolve it ?
Hi Ked,
I’m glad you are finding our e-mail example useful.
It would be hard to tell why you are getting the linker error without knowing what your project settings look like. However, you could try this: add the following option to your platformoptions.xml file (under the linkerOptions tag):
<linkerOptions> ... <option>-read_only_relocs suppress</option> ... <linkerOptions>Let me know if this works for you.
Radoslava
Hi
I need to send an attachment via e-mail client programatically in playbook using webworks sdk(existing code is done using webworks sdk)
I had implemented it in BlackBerry Curve using Java Extension in webworks sdk
But Jave Extension is not getting recognized in PlayBook emulator – am getting errors while building
Also I went through the post in
http://supportforums.blackberry.com/t5/Web-and-WebWorks-Development/How-to-programatically-send-email-using-Playbook-2-0/td-p/1612515/page/3
But there is no solution to add mail attachment
Also is it possible to use AIR extension as given in this post, for the mail attachment in PlayBook webworks
If possible could you give me the steps?
Also if there is any other way to send mail attachment in Playbook using webworks, please share it with me.
Thanks
Regards
Joel
Hi Joel,
The current extension only supports Apple iOS, so unfortunately you can’t use it out of the box for BlackBerry.
To make it work, it will need the native BlackBerry implementation added to it the same way the iOS Objective-C implementation was.
Are you a BlackBerry developer? If you would like to contribute a native implementation for that, we’d be happy to add you to the googleCode project.
Thanks,
Radoslava
Nice extension, but does it support multiple attachments?
Hi Ivan,
It does. You pass an array with information for each attachment to sendMail() – more details here: https://code.google.com/p/diadraw-air-email-native-extension-example/
Cheers,
Radoslava