Code Monkey home page Code Monkey logo

cordova-plugin-email-composer's Introduction

Cordova Email Plugin
npm version Code Climate PayPayl donate button

The plugin provides access to the standard interface that manages the editing and sending an email message. You can use this view controller to display a standard email view inside your application and populate the fields of that view with initial values, such as the subject, email recipients, body text, and attachments. The user can edit the initial contents you specify and choose to send the email or cancel the operation.

Using this interface does not guarantee immediate delivery of the corresponding email message. The user may cancel the creation of the message, and if the user does choose to send the message, the message is only queued in the Mail application outbox. This allows you to generate emails even in situations where the user does not have network access, such as in airplane mode. This interface does not provide a way for you to verify whether emails were actually sent.

Supported Platforms

  • Android
  • Browser
  • iOS
  • OSX
  • Windows

Installation

The plugin can be installed via Cordova-CLI and is publicly available on NPM.

Execute from the projects root folder:

$ cordova plugin add cordova-plugin-email-composer

Or install a specific version:

$ cordova plugin add cordova-plugin-email-composer@VERSION

Or install the latest master version:

$ cordova plugin add https://github.com/katzer/cordova-plugin-email-composer.git

Or install from local source:

$ cordova plugin add <path> --nofetch --nosave

Usage

The plugin creates the object cordova.plugins.email and is accessible after the deviceready event has been fired.

document.addEventListener('deviceready', function () {
    // cordova.plugins.email is now available
}, false);

All properties are optional. After opening the draft the user may have the possibilities to edit the draft from the UI. The callback comes without arguments.

cordova.plugins.email.open({
    from:       String, // sending email account (iOS only)
    to:          Array, // email addresses for TO field
    cc:          Array, // email addresses for CC field
    bcc:         Array, // email addresses for BCC field
    attachments: Array, // file paths or base64 data streams
    subject:    String, // subject of the email
    body:       String, // email body
    isHtml:    Boolean  // indicats if the body is HTML or plain text (primarily iOS)
}, callback, scope);

The following example shows how to create and show an email draft pre-filled with different kind of properties:

cordova.plugins.email.open({
    to:      '[email protected]',
    cc:      '[email protected]',
    bcc:     ['[email protected]', '[email protected]'],
    subject: 'Greetings',
    body:    'How are you? Nice greetings from Leipzig'
});

Of course its also possible to open a blank draft:

cordova.plugins.email.open();

Its possible to specify the email client. If the phone isn´t able to handle the specified scheme it will fallback to the system default:

cordova.plugins.email.open({ app: 'mailto', subject: 'Sent with mailto' });

On Android the app can be specified by either an alias or its package name. The alias gmail is available by default.

// Add app alias
cordova.plugins.email.addAlias('gmail', 'com.google.android.gm');

// Specify app by name or alias
cordova.plugins.email.open({ app: 'gmail', subject: 'Sent from Gmail' });

Issues with AndroidX

If you have issues with AndroidX, simply install the extra plugin

cordova plugin add cordova-plugin-androidx-adapter

For Ionic/Capacitor you can also try

npm install jetifier
npx jetify
npx cap sync android

HTML and CSS

Only the built-in email app for iOS does support HTML and CSS. Some Android clients support rich formatted text.

Use isHtml with caution! It's disabled by default.

Attach Base64 encoded content

The code below shows how to attach an base64 encoded image which will be added as a image with the name icon.png.

cordova.plugins.email.open({
    subject:     'Cordova Icon',
    attachments: ['base64:icon.png//iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6...']
});

Attach files from the device storage

The path to the files must be defined absolute from the root of the file system. On Android the user has to allow the app first to read from external storage!

cordova.plugins.email.open({
    attachments: 'file:///storage/sdcard/icon.png', //=> storage/sdcard/icon.png (Android)
});

Attach native app resources

Each app has a resource folder, e.g. the res folder for Android apps or the Resource folder for iOS apps. The following example shows how to attach the app icon from within the app's resource folder.

cordova.plugins.email.open({
    attachments: 'res://icon.png' //=> res/mipmap/icon (Android)
});

Attach assets from the www folder

The path to the files must be defined relative from the root of the mobile web app folder, which is located under the www folder.

cordova.plugins.email.open({
    attachments: [
        'file://img/logo.png', //=> assets/www/img/logo.png (Android)
        'file://css/index.css' //=> www/css/index.css (iOS)
    ]
});

Attach files from the internal app file system

The path must be defined relative from the directory holding application files.

cordova.plugins.email.open({
    attachments: [
        'app://databases/db.db3', //=> /data/data/<app.package>/databases/db.db3 (Android)
        'app://databases/db.db3', //=> /Applications/<AppName.app>/databases/db.db3 (iOS, OSX)
        'app://databases/db.db3', //=> ms-appdata:///databases/db.db3 (Windows)
    ]
});

Device Configuration

The email service is only available on devices which have configured an email account. On Android the user has to allow the app first to access account informations.

cordova.plugins.email.hasAccount(callbackFn);

To check for a specific mail client, just pass its uri scheme on iOS, or the package name on Android as first parameter:

cordova.plugins.email.hasClient('gmail', callbackFn);

For Android only, it's possible to get a list of all installed email clients:

cordova.plugins.email.getClients(function (apps) {
    cordova.plugins.email.open({ app: apps[0] });    
});

Permissions

Some functions require permissions on Android. The plugin itself does not add them to the manifest nor does it ask for by itself at runtime.

Permission Description
cordova.plugins.email.permission.READ_EXTERNAL_STORAGE Is needed to attach external files file:/// located outside of the app's own file system.
cordova.plugins.email.permission.GET_ACCOUNTS Without the permission the hasAccount() function wont be able to look for email accounts.

To check if a permission has been granted:

cordova.plugins.email.hasPermission(permission, callbackFn);

To request a permission:

cordova.plugins.email.requestPermission(permission, callbackFn);

Note: The author of the app has to make sure that the permission is listed in the manifest.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request

License

This software is released under the Apache 2.0 License.

Made with 😋 from Leipzig

© 2013 appPlant GmbH

cordova-plugin-email-composer's People

Contributors

adityasingh0208 avatar alex-nau avatar alimariam avatar barneyszabo avatar bboybboy avatar bentleyo avatar bnolan001 avatar chr05347560 avatar dylanvdmerwe avatar eddyverbruggen avatar emanfu avatar fhls avatar jcbobo avatar jeroendeswaef avatar jfoclpf avatar jordandoerksen avatar katzer avatar lukaslisowski avatar majinraph avatar mdkitzman avatar mdomi avatar mgcrea avatar mitko-kerezov avatar perimosocordiae avatar pierotofy avatar pknittel avatar rob212 avatar tatomyr avatar theduc avatar ywplee avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-plugin-email-composer's Issues

feedback some issues for you

I am using phonegap build 3.3 with your latest plugin 0.7.1

My device
Android 4.03, iOS 7.0.6,Windows phone 8 (Nokia Lumia 520)

Q1
When I use this method

window.plugin.email.isServiceAvailable(
    function (isAvailable) {
        alert(isAvailable ? 'Service is available' : 'Service NOT available');
    }
);

Android:Service is available (good,I use a Gmail account)
iOS:Service is available (good,I use a Gmail account)
Windows phone:Service is available (so strange,I have no account in my device)

Q2
When I use this method

window.plugin.email.open({
    to:      ['[email protected]'],
    cc:      ['[email protected]'],
    bcc:     ['[email protected]', '[email protected]'],
    attachments: ['......'],
    subject: 'Hello World!',
    body:    '<h3>TEST</h3><h2>TEST</h2><h1>TEST</h1>',
    isHtml:  true
});

Android:almost work (In addition "cc" and "bcc",I am using Gmail app to send a mail)
iOS:all work (In addition "attachments")
#14

attachment prefixes "relative" seem not work

I am using PGB 3.3 with latest plugin 0.8.0 in Android (ios and winphone not try yet)

Q1
when I use

attachments: ['absolute://storage/sdcard/download/4110.apk']
or
attachments: ['/sdcard/download/4110.apk']

it will work and attach my 4110.apk file to my email

but when I use

attachments: ['relative://drawable/icon']
or
attachments: ['relative://drawable/icon.png']

http://www.littlebau.com/relative.gif
it will not work (just no response or appear any wrong message)

Q2
in this page
https://github.com/katzer/cordova-plugin-email-composer/blob/0cc829af59b94b52db63a999064577a6962bf763/README.md
it told me...

in Android,relative path must be point to a file from the "res" folder
http://www.littlebau.com/relative.gif

in iOS,relative path must be point to a file from the "root" folder
http://www.littlebau.com/relative_ios.gif
but I don't know which one is the "root" folder by ios @@

Unable to use it with phonegap 3.4

I have been trying to use this plugin in android for quite few days now but failing. I have followed all the steps mentioned in the readme file but all in vain. Here are the steps that I followed:
1> added the <gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.0" /> in config.xml
2> installed the plugin by running this command in phonegap cli -
phonegap local plugin add

I also tried to solve the issue by following this tutorial: Issue#9
but that didnt work out for me. Please help.

android html

email-composer-plugin 0.8.0
cordova 3.3.0 and android 4.2.2

Ciao Sebastián, html on Android is shown as plain text, try this:

var htmBody = "test for <strong>android</strong> html <a href='http://www.google.com'>google</a>";

window.plugin.email.open({
        to:          [],
        cc:          [],
        bcc:         [],
        attachments: [],
        subject:     "android html text",
        body:        htmBody,
        isHtml:      true,
    });

plugin throws errors on cordova/phongap 3.1

Hi,

I've installed the plugin on cordova 3.1 and I'm getting the following 2 errors whenever I'm trying to use it.

When I load the app to my android device:
11-08 15:47:25.689: E/Web Console(29177): Uncaught ReferenceError: module is not defined at file:///android_asset/www/js/email_composer.js:51

When I invoke window.plugin.email.open
11-08 15:54:07.348: E/Web Console(29177): Uncaught TypeError: Converting circular structure to JSON at file:///android_asset/www/cordova.js:901

Any help is highly appreciated.
Thanks

the "Android" terrible problem

iOS,ipad mini,7.0.4
Android,HTC Sensational XL,4.0.3

iOS and Android will success execute "window.plugin.email.open"

in iOS,when I click "cancel" button,it will "reback" to the app
but..
in Android,when I click "Discard Drafts" button,it will "reopen" to the app Immediately
http://www.littlebau.com/reopen.png

Feature request: callbacks

Would it be possible to add a complete callback function that fires when the app returns from sending emails (or cancelling - I know you probably can't tell the difference).

Problems attaching audio file to email

I'm unable to attach an audio file to an email in Android. Using the Android "Mail" client, the client says the attachment is corrupted. I know that it is not corrupted because I can play it back fine. I've tried the following paths, but both result in the same message:

file:///data/data/com.willswebworks.recovery/files/journal/journalEntry-1.amr
/data/data/com.willswebworks.recovery/files/journal/journalEntry-1.amr

Any ideas?

How to use this plugin

I followed instructions given in the ReadME file, but unable to run this plugin on the app.
Is there extra configuration settings needed for using this plugin with cordova 3.0.0

Issue on iOS platform

I have used the plugin in my project .As its working fine on android but not working on iOS platform . Can anyone help me out.

Installation

If you have hydrated app and want to install e-mail composer - uninstall and install app on device. Just like geolocation email composer must have permissions on app installation.

csv file attachment

Hi Sebastian,

This is probably an enhancement more than an issue, but I don't seem to be able to send a csv file nor a txt file. It shows up in the composer, but when I click 'send' it doesn't appear in the mail of the recipient.

He gets the mail without an attachment.. Is this some iPad feature or third party application I should have to be able to send this?

Thank you and my apologies if this is off topic

App wont build for ios

It worked fine till yesterday but now when I try to build a project it says this:
The following build commands failed:
CompileC build/eSmPC2.build/Debug-iphonesimulator/eSmPC2.build/Objects-normal/i386/CDVFile.o eSmPC2/Plugins/org.apache.cordova.file/CDVFile.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
CompileC build/eSmPC2.build/Debug-iphonesimulator/eSmPC2.build/Objects-normal/i386/CDVFileTransfer.o eSmPC2/Plugins/org.apache.cordova.file-transfer/CDVFileTransfer.m normal i386 objective-c com.apple.compilers.llvm.clang.1_0.compiler
(2 failures)

at ChildProcess.<anonymous> (/usr/local/lib/node_modules/cordova/src/compile.js:65:22)
at ChildProcess.EventEmitter.emit (events.js:98:17)
at maybeClose (child_process.js:735:16)
at Process.ChildProcess._handle.onexit (child_process.js:802:5)

The only difference is that I changed provisioning profile. when I remove this plugin build passes.

name of file

Hi. Thx for the nice plugin.
The files i send don't have the right name. It is like : attachment1.jpg, attachment2.jpg ...
Is there any way to send the right names? Thx

HTML markup is stripped in Android's default email app

HTML markup (not just CSS) is stripped out of the message body in Android's default email app.

        window.plugin.email.open({
                        subject:    'Test',
                        body:       '<h1>Test</h1><a href="http://google.com'">Test</a>',
                        isHtml:     true,
                    }, emailCallback);

Tried sending the message to my gmail address. Received a plain text email with no hyperlink or formatting:

 Test
 Test

Tested on Android emulator platform 4.4.2 API level 19.

Plugin 'EmailComposer' not found, or is not a CDVPlugin.

Hi,
Here are issue when install Cordova plugin email composer, only iOS:

Step 1: cordova plugin add https: //github.com/katzer/cordova-plugin-email-composer.git

config.xml
< feature name="EmailComposer">
< param name="ios-package" value="APPEmailComposer" />
</ feature>
Step2:
window.plugin.email.open({
to: ['[email protected]'],
cc: ['[email protected]'],
bcc: ['[email protected]', '[email protected]'],
subject: 'Greetings',
body: 'How are you? Nice greetings from Leipzig'
});

Step3: build app
-> error message:

ERROR: Plugin 'EmailComposer' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.

Please you recheck.
Thanks,

email.isServiceAvailable() gives false negative on HTC One

Just to let you know that I was using your window.plugin.email.isServiceAvailable() method to check for email configuration and was getting the error callback on a properly configured HTC One.

I removed the check method and just tried to open email and it works fine (therefore leading me to believe the isServiceAvailble method is not recognizing a correct email configuration of this variety).

Some limited details on the device:

// device: HTC One // platform: Android 4.3 // cordova: 3.3.0

adding a body causes "attempt to cast generated internal exception"

The following occurs whenever I add a body to my email

04-24 19:52:24.489: W/Bundle(10264): Key android.intent.extra.TEXT expected ArrayList<CharSequence> but value was a java.lang.String.  The default value <null> was returned.
04-24 19:52:24.489: W/Bundle(10264): Attempt to cast generated internal exception:
04-24 19:52:24.489: W/Bundle(10264): java.lang.ClassCastException: java.lang.String cannot be cast to java.util.ArrayList
04-24 19:52:24.489: W/Bundle(10264):    at android.os.Bundle.getCharSequenceArrayList(Bundle.java:1367)
04-24 19:52:24.489: W/Bundle(10264):    at android.content.Intent.getCharSequenceArrayListExtra(Intent.java:4736)
04-24 19:52:24.489: W/Bundle(10264):    at android.content.Intent.migrateExtraStreamToClipData(Intent.java:7252)
04-24 19:52:24.489: W/Bundle(10264):    at android.content.Intent.migrateExtraStreamToClipData(Intent.java:7219)
04-24 19:52:24.489: W/Bundle(10264):    at android.app.Instrumentation.execStartActivity(Instrumentation.java:1417)
04-24 19:52:24.489: W/Bundle(10264):    at android.app.Activity.startActivityForResult(Activity.java:3424)
04-24 19:52:24.489: W/Bundle(10264):    at android.app.Activity.startActivityForResult(Activity.java:3385)
04-24 19:52:24.489: W/Bundle(10264):    at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:859)
04-24 19:52:24.489: W/Bundle(10264):    at de.appplant.cordova.plugin.emailcomposer.EmailComposer$1.run(EmailComposer.java:124)
04-24 19:52:24.489: W/Bundle(10264):    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
04-24 19:52:24.489: W/Bundle(10264):    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
04-24 19:52:24.489: W/Bundle(10264):    at java.lang.Thread.run(Thread.java:841)

Font style and format on email app

When trying to send an email on iOS it sends the email with the same font type and formatted. When sending an email on Android using the default mail app the font is not the same neither it is formatted.

Is this a problem with any plugin option?

BR

Multiple Attachments not working in Android

window.plugin.email.open({
to: ['[email protected]', '[email protected]'],
subject: 'Hello',
body: 'download files',
attachments: ['file:///storage/sdcard0/xxx/filename.xls','file:///storage/sdcard0/xxx/filename.pdf'],
isHtml: true
});

Only the 2nd attachment gets attached in the composer. Rather when multiple attachments are there only the last one is attached in the composer.

the "attachments" method not work~

iOS,ipad mini,7.0.4
Android,HTC Sensational XL,4.0.3

when I set "attachments" method like this(only this method not work)

attachments: ['https://www.google.com/images/srpr/logo4w.png'],

but it's not work with ios and android

Attachement is not working

Hello
i am using this plugin for jquerymobile+phonegap for IOS. while i am sending the image data as attachment as base 64 string() as you showed in the examples..
window.plugin.email.open({
subject: 'Cordova Icon',
attachments: ['base64:icon.png//iVBORw0KGgoAAAANSUhEUgAAADwAAAA8CAYAAAA6/...']
});

it show me the encoded attachment on the device. and while receiving its not showing anything at all.

Thanks
Avneet

Attach a file created with cordova 3.3 or 3.4

Hello, I am using your plugin to send a mail with some data. Now I need to attach a file and I am a little lost on how to do it consistently for iOS and android. In android, I create a file to store it in persistent file system (ie: /myApFileSystem/test.pdf), to include in attachments array structure I must prefix with "absolute://sdcard/", this works fine, but in ios I cannot know (at least I do not notice) the absolute file path (see https://github.com/apache/cordova-plugin-file/blob/master/doc/index.md). I try with relative prefix but I cannot get the right way to do it (I try 'relative://myApFileSystem/test.pdf').
Can you guide me on how to set the string path for attachments ?

Wrong attachment path

Hi.

I'm testing this pugin with Phonegap Build.

All works fine but I can't attach an image.

I'm using the camera to capture image and send email composer the URI of image.

The path is like: file:///var/mobile/Applications/......../tmp/cdv_photo_001.jpg

I tried to slice the firsts character but doesn't work.

How can I attach image to email?

Thanks.

Cannot I send email without showing the user the email open

I need to send a predefined email to app users when they finish but not use their email I want to set my email pop / map details, like what you would do with php,asp.net to send mail from one account? So I can track who was sent a email.

Hope this makes sense.

Thanks
Mo

configuring config.xml for wp7 platform for emailcomposer

When i install the plugin for WP7 platform what should we configured in congif.xml file.
I followed steps by specifining <gap:plugin name="de.appplant.cordova.plugin.email-composer" /> in config.xml but it give error that <gap is undefined.
I also tried specifiing feature with name and value as "EmailComposer".

I am using cordova version 3.1.0

will be thankfull to you if theres any solution for it.

android base64 attachment: file not found

Testing on Android 4.1.1, plugin version 0.8.1dev:

Trying to send a base64 encoded file as attachment fails with the error message:
W/Gmail ( 2557): Failed to attach content://de.appplant.cordova.plugin.emailcomposer.attachmentprovider/blubb.zip due to a FileNotFoundException. Since the cached file has already been tried, this file cannotbe attached. Notify the user.

Here is a relevant code snippet:

        var zip = new JSZip();
        zip.file("Hello.txt", "Hello World\n");
        var content = zip.generate();
        var b = 'base64:blubb.zip//'+content;
        console.log(a);

        var subject = "subject";
        window.plugin.email.open({
            to          : toEmail || [],
            cc          : [],
            bcc         : [],
            subject     : subject,
            body        : mailContent,
            attachments : [b],
            isHtml      : true
        });

I can't currently spend too much time on this and my android is not very good, but is it possible that in EmailComposer.java you are not respecting the '/email_composer/' directory that you created when building the return Uri of the getUriForBase64Content method or something like that?

Issues and questions

Hi there. Im using the plugin and I would like to report some issues and ask some questions:

In my application, the user can see data sent from a server and then he can chose weather he wants to send this data through email.

1 - I can't use CSS on the email body. It simply doesn't apply any style.
2 - I can't get the img tag (< img >) to work! It just shows me "Obj" on the email (using android with gmail client). How am I suppose to put the image file path?
3 - The plugin causes lost of context which means after the user selects to send the email and come back to the app, the app is restarted, which is not interesting in my case for the user should be able to select another data to send.

Can you help me there?

Thanks in advance.

Trying to make it work on Cordova 2.9

I am still using Cordova 2.9 so I installed the plugin manually

1- I do not know how window.plugin.email.open can work at all, looking at the js only plugin is exported, so I am using window.plugin.open to trigger the email composer. Is this because I installed it manually? Anyway this way it works.

2- I had to comment out the lines of code within the execCallback function in APPEmailComposer.m because that was crashing my app. Now it works, but I do not get any callback when the email is sent and the composer panel is dismissed...

I am calling the plugin like:

window.plugin.open({
    to : [mailto], 
    cc : [],
    bcc : [], 
    attachments : ["var/mobile/Applications/MYAPP_ID/Documents/file.txt"], //
    subject : subject, 
    body : body, 
    isHtml : true
    }, sendStatus, this);

How can I get sendStatus to be called after the panel is dismissed?

This is the line in xCode causing the problem:
[self.commandDelegate sendPluginResult:result callbackId:_command.callbackId];

triggering an error thread 1 exc_bad_access on _command

xCode 5 and iOS 7

Thanks

Issues sending email for iphone 5s ** Can be deleted see my comment **

Are there any differences between the iPhone 5 and 5s that would cause issues for sending email using this plugin? I have two test users with ios v7.1.1 iPhone 5s that can not send email. The iPhone 5 can email while anyone with a 5s can't. Is this a bug?

application details:
phonegap
cordova 3.2
Jquery mobile 1.4.2
Jquery 1.11.0

Does it work with Android Phonegap 3.3.0 ?

I created new Android project with phonegap 3.3.0 using the cmd interface. I can run the phonegap on my android phone. Tried to follow your instruction to install the plugin email composer but I every time I run the code window.plugin.email.open(); I got this error

Uncaught TypeError: Cannot call method 'open' of undefined:43

Below is my index.html

<html>
<head>
<meta charset="utf-8" />
<meta name="format-detection" content="telephone=no" />
<!-- WARNING: for iOS 7, remove the width=device-width and height=device-height attributes. See https://issues.apache.org/jira/browse/CB-4323 -->
<meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width, height=device-height, target-densitydpi=device-dpi" />
<link rel="stylesheet" type="text/css" href="css/index.css" />
<title>Hello World</title>
</head>
<body>
<div class="app" onclick="emailme();">
<h1>Apache Cordova</h1>
<div id="deviceready" class="blink">
<p class="event listening">Connecting to Device</p>
<p class="event received">Device is Ready</p>
</div>
</div>
<script type="text/javascript" src="cordova.js"></script>
<script type="text/javascript" src="js/email_composer.js"></script>
<script type="text/javascript" src="js/index.js"></script>

<script type="text/javascript">
app.initialize();
function emailme(){
window.plugin.email.open();
}
</script>
</body>
</html>

email_composer.js already put inside "js" folder

What should I do ?

Thanks

Missing framework link

The MessageUI Framework isnt added to the project after the plugin was added.
The following line from plugin.xml seems not to working:

<framework src="MessageUI.framework" weak="true" />

cant get it working on android

I am trying to use this plugin on a small app, but when I do

window.plugin.email.open();

Nothing happens.

If I try to do this from console (using Weinre debugger) I get an "undefined" response

plugin is configured on config.xml and the app is built using PhoneGap Build

I'm using phonegap version 3.4.0 with Onsen UI (Angular.js)

App doesn't startup on Android

I'm trying to port my existing iOS application to android, haven't done any tweaks yet just a quick & dirt try.

So I used 'phonegap build android' and imported the android files to eclipse now if I want to start it on my tab 4 I got the following error log:

07-12 14:06:16.844: E/AndroidRuntime(26767): FATAL EXCEPTION: main
07-12 14:06:16.844: E/AndroidRuntime(26767): Process: de.mo.mepantrag, PID: 26767
07-12 14:06:16.844: E/AndroidRuntime(26767): java.lang.RuntimeException: Unable to get provider de.appplant.cordova.plugin.emailcomposer.AttachmentProvider: java.lang.ClassNotFoundException: Didn't find class "de.appplant.cordova.plugin.emailcomposer.AttachmentProvider" on path: DexPathList[[zip file "/data/app/de.mo.mepantrag-3.apk"],nativeLibraryDirectories=[/data/app-lib/de.mo.mepantrag-3, /vendor/lib, /system/lib]]
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.installProvider(ActivityThread.java:5118)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.installContentProviders(ActivityThread.java:4710)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.access$1600(ActivityThread.java:169)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1337)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.os.Handler.dispatchMessage(Handler.java:102)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.os.Looper.loop(Looper.java:136)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.main(ActivityThread.java:5479)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at java.lang.reflect.Method.invokeNative(Native Method)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at java.lang.reflect.Method.invoke(Method.java:515)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1283)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1099)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at dalvik.system.NativeStart.main(Native Method)
07-12 14:06:16.844: E/AndroidRuntime(26767): Caused by: java.lang.ClassNotFoundException: Didn't find class "de.appplant.cordova.plugin.emailcomposer.AttachmentProvider" on path: DexPathList[[zip file "/data/app/de.mo.mepantrag-3.apk"],nativeLibraryDirectories=[/data/app-lib/de.mo.mepantrag-3, /vendor/lib, /system/lib]]
07-12 14:06:16.844: E/AndroidRuntime(26767):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
07-12 14:06:16.844: E/AndroidRuntime(26767):    at android.app.ActivityThread.installProvider(ActivityThread.java:5103)
07-12 14:06:16.844: E/AndroidRuntime(26767):    ... 12 more

I understood that it couldn't find the AttachmentProvider class, but why ? I also couldn't find the file in my platform/android directory. So where is it ? Or maybe I failed installing the plugin.. but works like charm on iOS.

Cheers Marvin

file not exists base64

Hi,

I can't attach file in base64 formats. I have device Samsung Note 3 (SM-N9005), Android 4.4.2.
I'm using this code.
window.plugin.email.open({
subject: 'hi there',
body: 'file for you',
isHtml: true,
attachments: [dataURL]
});
On the other device with android 4.0.x it is working.

Error Creating Draft

On this line in EmailComposer.java

draft.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(body));

I'm getting the following error.

Key android.intent.extra.TEXT expected ArrayList but value was a android.text.SpannableStringBuilder. The default value was returned.

I have found a few articles containing similar issues but I am not familiar with Java so I do not know how to create the proper cast. I will keep working on it but if there is a fix please let me know.

iOS App crashes after attachment

I'm using this plugin in conjunction with file transfer plugin. While with emails without attachments it works fine, as soon as I attach a PDF, the app crashes.

The file transfer plugin stores the PDFs in "cdvfile://localhost/persistent/path/to/downloads/" folder and I am passing the same file name for the attachments. I am not sure if it can read the file at all, maybe the path should be different.

Appreciate any help.

Including <img> tag in the body

Is it possible to include an image tag in the body.

I have something like:
window.plugin.email.open({
body: "<img src='http://validimage.com/image.jpg' /><br /><a href='http://github.com' >here</a>",
isHtml: true
});

The link is created properly, but instead of getting the image, even though I checked the URL to make sure it is valid, it displays an [obj] tag.

I'm trying this on a Android device. At this moment I don't know if the problem is with the plug in or with the mobile device itself.

Thanks

html iOS ok - html Android not formatting

Ciao Sebastián !!!

html with css works great on iOS, but Android returns all the plain text of the html file except html tags, in the body.

(e-mail account created and working)

after calling the email composer function Android prompts the [Select Email App popup] Tap on "E-mail"

to: OK
subject: OK
body: no html formatted but just plain text (showing the whole html text except html tags)

Compile error on iOS

What exactly is the solution to this problem?

I have deleted and reinstalled the MessageUI.framework but I still get the error.
Do I have to use another framework?

Thank you and my apologies if the answer if very obvious, but I don't seem to find it.

java.lang.SecurityException for Android 4.3 when attaching base64-encoded image

I am using verstion 0.8.1 of the plugin with a Samsung Galaxy Grand2 (android 4.3). When i attach a base64-encoded png file i get a java.lang.SecurityException: Provider .................. does not allow granting of Uri permissions.
Adding android:grantUriPermissions="true" to plugin.xml solves the issue.
Do u think this is the proper solution or is there any other workaround?

(Android build problem,ios or winphone not try yet) 0.8.0 version have a strange problem

I am using PGB (build.phonegap.com) 3.3 with your latest plugin 0.8.0

if I add this plugin to my config.xml and build it

<gap:plugin name="de.appplant.cordova.plugin.email-composer" version="0.8.0" />

it will build success
download the apk success
but...when I install the apk file through PGB,Installation will fail

if I don't use this plugin
build,download,Installation,all of them success

trust me
I tried many times to find this issues,very hard work

can not work on android

Hi there:
i just have a sample in IOS&ANDROID,
everythins is ok but in android

when use plugin.email.isServiceAvailable
it always get 'false' .

my android device is XIAOMI 2A (made in china ),MIUI rom.
email app installed.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.