1

I've built a simple jQuery Mobile based app, and trying to compile it with Phonegap. I'd like the users to be able to send some content from the app via email, but I can't figure this out.

My code:

<script type="text/javascript" src="json2.js"></script>
<script type="text/javascript" charset="utf-8" src="phonegap.js"></script>
<script type="text/javascript" src="EmailComposer.js"></script> 
<script src="js/jquery-1.5.min.js"></script>
<script src="js/jquery.mobile-1.0a3.min.js"></script>
<script src="js/jsStuff.js"></script>
<script type="text/javascript" charset="utf-8">

// Wait for PhoneGap to load
//
function onLoad() {
    document.addEventListener("deviceready", onDeviceReady, false);
}

// PhoneGap is ready
//
function onDeviceReady() {
    // Empty
}

// alert dialog dismissed
function alertDismissed() {
    // do something
}

// Show a custom alert
//
function doEmail() {
    window.plugins.emailComposer.showEmailComposer("Subject","PlainTextBody", "recipient,recipient", "ccRecipient", "bccRecipient",false);
}
</script>

<link rel="stylesheet" href="style.css" /> 

And then:

<body onload="onLoad()"> 
<a href="#" onclick="doEmail(); return false;">Send email</a>

This does nothing at all.

What I've done:

  1. Downloaded the EmailComposer plugin.
  2. Move EmailComposer.js to the root of my app (Phonegap project -> www).
  3. Added EmailComposer.h & EmailComposer.m to my project by right-clicking my www folder in Xcode, then "Add" --> "Existing Files..." (REference type: Default, "copy items into destination..." is checked)
  4. Added MessageUI.framework to my project by right clicking my project's target -> "Get info" and adding it to linked libraries.

Any help would be appreciated.

Francisco R
  • 4,032
  • 1
  • 22
  • 37
Adam Tal
  • 921
  • 5
  • 14
  • 35
  • Could you add some links about the email composer plugin? Also - use a try-catch block to alert any errors generated by the line calling `showEmailComposer` – naugtur Feb 21 '11 at 20:34
  • I think he's using this code: https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/EmailComposer – fil maj Feb 21 '11 at 22:45

7 Answers7

4

Okay, I know this is an old thread but it looks like the correct answer has not been posted. For future readers who may stumble on this:

You have to add the EmailComposer plugin into your PhoneGap.plist file, under plugins add a new row with "EmailComposer" in the left column, and "EmailComposer" in the right column.

2

You must add the plugin into the PhoneGap.plist.

Add a new entry with Key "EmailComposer" and value "EmailComposer"

ofuchs
  • 21
  • 1
1

As naugtur suggested, try some troubleshooting techniques, like.. does it work if you remove temporarily those custom scripts: jsStuff.js and json2.js? I know they may be required in your app but it may help you locate the source of the problem. Try sending console messages or alerts inside you doEmail function. Hope it helps.

Phobox
  • 143
  • 2
  • 11
0

For those finding this question whilst trying to get an Email Composer to work, you no longer need to add things to the plist. The new CLI interface handles that for you.

The most current version of the Email Composer plugin is here - https://github.com/katzer/cordova-plugin-email-composer

And the way to add it to your project is this in the command line: cordova plugin add de.appplant.cordova.plugin.email-composer && cordova prepare

Joshua Dance
  • 8,847
  • 4
  • 67
  • 72
0

Seems like the problem was related to the way I added the plugin files to the xCode project. If you need extra details: http://groups.google.com/group/phonegap/browse_thread/thread/6fd7d73d3532effd/4ae9daa0b746ceb5#4ae9daa0b746ceb5

Adam Tal
  • 921
  • 5
  • 14
  • 35
0

Add to PhoneGap.plist Plugins: key 'com.phonegap.emailComposer' value 'EmailComposer'.

Darkngs
  • 6,381
  • 5
  • 25
  • 30
-1

I think you have to change it to <a href="javascript:doEmail()">Send Mail</a> , onclick isn´t a iphone event