Giter VIP home page Giter VIP logo

cordova-email-plugin's Introduction

Cordova Email Plugin

Greenkeeper badge

Build Status Build status npm version Dependency Status devDependency Status

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.

NPM

Feel free to donate

Click here to lend your support and make a donation at www.pledgie.com ! Or donate Bitcoins: bitcoin:3NKtxw1SRYgess5ev4Ri54GekoAgkR213D

Bitcoin

Also via greenaddress

Installation

$ cordova plugin add cordova-plugin-email

Or if you want to use the development version (nightly build), which maybe not stable!:

cordova plugin add cordova-plugin-email@next

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.

Overview

  1. Supported Platforms
  2. Installation
  3. ChangeLog
  4. Using the plugin
  5. Examples
  6. Quirks

Supported Platforms

  • iOS
  • Android
  • Amazon FireOS
  • Windows
  • Browser

PhoneGap Build

Add the following xml to your config.xml to always use the latest version of this plugin:

<gap:plugin name="cordova-plugin-email-composer" version="0.8.3" source="npm" />

Changelog

  • See CHANGELOG.md to get the full changelog for the plugin.

Using the plugin

The plugin creates the object cordova.plugins.email with following methods:

  1. email.isAvailable
  2. email.open

Plugin initialization

The plugin and its methods are not available before the deviceready event has been fired.

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

Determine if the device is capable to send emails

The ability to send emails can be revised through the email.isAvailable interface. The method takes a callback function, passed to which is a boolean property. Optionally the callback scope can be assigned as a second parameter.

The Email service is only available on devices capable which are able to send emails. E.g. which have configured an email account and have installed an email app. You can use this function to hide email functionality from users who will be unable to use it.

cordova.plugins.email.isAvailable(
    function (isAvailable) {
        // alert('Service is not available') unless isAvailable;
    }
);

If you want to open a draft in a specific application, just pass its uri scheme on iOS, or its name on Android as first parameter, to check whether the application is installed or not. The callback function will return a second parameter of type boolean then.

cordova.plugins.email.isAvailable(
    urischeme, function (isAvailable, withScheme) {
        // alert('Service is not available') unless isAvailable;
    }
);

Note: If the user didn't have any email account configured on iOS this will also return false

Open a pre-filled email draft

A pre-filled email draft can be opened through the email.open or email.openDraft interface. The method takes a hash as an argument to specify the email's properties. All properties are optional. Further more it accepts an callback function to be called after the email view has been dismissed.

After opening the draft the user may have the possibilities to edit, delete or send the email.

Further informations

  • An configured email account is required to send emails.
  • Attachments can be either base64 encoded datas, files from the the device storage or assets from within the www folder.
  • The default value for isHTML is true.
  • Its possible to specify the email app on Android and iOS.
  • See the examples for how to create and show an email draft.
cordova.plugins.email.open({
    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 (for HTML, set isHtml to true)
    isHtml:    Boolean, // indicats if the body is HTML or plain text
}, callback, scope);

Examples

Open an email draft

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();

Send HTML encoded body

Its possible to send the email body either as text or HTML. In the case of HTML the isHTML properties needs to be set.

cordova.plugins.email.open({
    to:      '[email protected]',
    subject: 'Greetings',
    body:    '<h1>Nice greetings from Leipzig</h1>',
    isHtml:  true
});

When building for the browser, you cannot use HTML in the body content. Internally, this plugin generates a "mailto:"-style link to support browsers, and the mailto URI scheme only supports plain text body content. See RFC6068 for more details on mailto URIs.

Get informed when the view has been dismissed

The open method supports additional callback to get informed when the view has been dismissed.

cordova.plugins.email.open(properties, function () {
    console.log('email view dismissed');
}, this);

Adding attachments

Attachments can be either base64 encoded datas, files from the the device storage or assets from within the www folder.

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.

cordova.plugins.email.open({
    attachments: 'file:///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/drawable/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)
    ]
});

Specify email app

Its possible to specify the email app which shall open the draft for further editing. Just pass its scheme name through the drafts app-attribute. If the phone isn´t able to handle the specified scheme it will fallback to standard.

// Specify app by scheme name
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'
})

Quirks

HTML and CSS on Android

Even Android is capable to render HTML formatted mails, most native Mail clients like the standard app or Gmail only support rich formatted text while writing mails. That means that CSS cannot be used (no class and style support).

The following table gives an overview which tags and attributes can be used:

  • <a href="...">
  • <b>
  • <big>
  • <blockquote>
  • <br>
  • <cite>
  • <dfn>
  • <div align="...">
  • <em>
  • <font size="..." color="..." face="...">
  • <h1>
  • <h2>
  • <h3>
  • <h4>
  • <h5>
  • <h6>
  • <i>
  • <img src="...">
  • <p>
  • <small>
  • <strike>
  • <strong>
  • <sub>
  • <sup>
  • <tt>
  • <u>

HTML and CSS on Windows

HTML+CSS formatted body are not supported through the native API for Windows.

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

Development

Testing

Android and iOS Tooling setup, see

export PLATFORM=android # or ios ..
npm run clean && npm run setupDemoApp && npm run build

License

This software is released under the Apache 2.0 License.

© 2013-2016 appPlant UG, Inc. All rights reserved

cordova-email-plugin's People

Contributors

barneyszabo avatar bboybboy avatar bentleyo avatar chr05347560 avatar danbucholtz avatar eddyverbruggen avatar edwardcrane avatar emanfu avatar frontweb avatar greenkeeper[bot] avatar hypery2k avatar jcbobo avatar johnellmore avatar katzer avatar lukaslisowski avatar mabdurrahman avatar markdon avatar mdomi avatar mobilabgit avatar pierotofy avatar pknittel avatar rob212 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

cordova-email-plugin's Issues

Crash when checking availability

The plugin crashes with the following error when it checks for the availability (see screenshot).

*** Terminating app due to uncaught exception 'NSRangeException', reason: '*** -[__NSArrayM objectAtIndex:]: index 0 beyond bounds for empty array'
*** First throw call stack:
(0x1890821c0 0x187abc55c 0x188f5e4ac 0x1001916dc 0x10034925c 0x10034921c 0x1003572d4 0x100358e6c 0x100358bb8 0x1881162b8 0x188115da4)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)

screenshot

I'm using the plugin in combination with Ionic 2 RC.2 and Ionic Native. The app is running on a real device with iOS 10.1.1.

My code:

    let address: string = '...';
    let subject: string = '...';
    
    EmailComposer.isAvailable().then((available: boolean) => {
      if(available) {
        let email = {
          to: address,
          subject: subject,
          isHtml: false
        };

        EmailComposer.open(email);
      }
      else {
        // Fallback
      }
    });
System information:

Cordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.2
Ionic CLI Version: 2.1.4
Ionic App Lib Version: 2.1.2
Ionic App Scripts Version: 0.0.39
ios-deploy version: 1.9.0
ios-sim version: 5.0.9
OS: Mac OS X Sierra
Node Version: v7.0.0
Xcode version: Xcode 8.1 Build version 8B62

Attachments don't work on Android devices with new GMail Version

Hi Team,
I'm trying to get the plugin to work with attachments but I'm having serious problems with Android devices wich are using GMail as mail client. I get this error message from gmail "Permission denied for the attachment".

GMail 5.0 added some security checks to attachments it receives from an Intent. These are unrelated to unix permissions, so the fact that the file is readable doesn't matter.

Any help?
I am using the IonicFramework V2 with Angular 2

EmailComposer.isAvailable().then(() => {
    let email = {
        attachments: [
            'file:///data/user/0/de.leuze.dcrConfigurator/files/configs/dcr2xxi_config_1.bct'
        ],
        subject: "MyTest",
        body: "",
        isHtml: true
    };
    // Send a text message using default options
    EmailComposer.open(email, this).then(() => { });
}).catch((reason) => {
    console.log(reason);
});

Regards Michael

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/41462901-attachments-don-t-work-on-android-devices-with-new-gmail-version?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github).

Compatibility question

Hello,

I was just wondering if this plugin also works on iOS 9 aswell on Windows Phone 10?

Greetings
Graphefruit

plugin version 1.1.0, version iOS 9, cordova 6.1.1

i've installed due "cordova plugin add" and now the master branch from a local directory.
The Plugin is not working on iOS (iPhone 6, iOS 9.3.1).

There is no error, just isAvailable returns false.
Callback from cordova.plugins.email.open() returns false too (if i omit the isAvailable-Check).

Use language of OS

my app is in Dutch, the popup that appears on Android asking which app to use is English where other plugins (like https://www.npmjs.com/package/cordova-plugin-x-socialsharing) are in the set language.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40232487-use-language-of-os?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github).

iOS: isAvailable is true when default Mail app is not installed

iOS 10.2
Cordova 6.4.0

When default Mail app is uninstalled on iOS, system shows the attached screen, and isAvailable is immediately resolved to true. So when user clicks Cancel, cordova.plugins.email.open fails to launch any apps.

restore

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40897910-ios-isavailable-is-true-when-default-mail-app-is-not-installed?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github).

Issued cordova_not_available

I use Ionic 3

this is my code

import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { EmailComposer } from '@ionic-native/email-composer';

@Component({
  selector: 'page-contact',
  templateUrl: 'contact.html',
  providers: [EmailComposer]
})
export class ContactPage {

 email:any = {};
  constructor(public navCtrl: NavController, public navParams: NavParams,private emailComposer: EmailComposer) {
  }

senEmail(){
this.emailComposer.isAvailable().then(() =>{
   let email = {
    to: this.email.user_email,
    cc: '',
    bcc: [''],
    subject: 'Cordova Icons',
    body: 'How are you? Nice greetings from Leipzig',
    isHtml: true
  };
  this.emailComposer.open(email);
},(err)=>{
   console.log(err);
});


}

}

I just try send the email but I recive this error

cordova_not_available

any help ?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Unable to attach file due to IO error

The plugin is asking user to select email app to use. For my test I am using Outlook email App. It opens the app, populates the TO, Subject and Msg of the body just fine, but then I get a specific error:

Unable to add attachment due to IO error

I am attaching the file as such, the userdata.json file does exist (as its created upon app start up and I can read/write back into it during the app usage.

'cordova.file.dataDirectory = file:///data/data/com.ionicframework.myApp/files/'

cordova.plugins.email.open({
to: ["[email protected]"],
subject: title + " : " +sub,
body : msg,
attachments: cordova.file.dataDirectory + "userdata.json",
isHtml: 0,
}, function(){ console.log("Email cancelled")},
this
) ;

Callback for sent/dismissed email

Currently callback function in cordova.plugins.email.open doesn't provide any arguments, though it would be great to know whether user has actually sent email or dismissed the screen. For instance, similar cordova-sms-plugin provides success and error callbacks to handle cancelation. So if app relies on sending some crucial data, it can at least show warning when SMS screen was canceled.

NOTE: partially a duplicate of #19, but that issue was closed as invalid because it contained another question. This one was not solved.

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/40897253-callback-for-sent-dismissed-email?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github).

Not send email in IONIC 2

      sendEmail() {
          EmailComposer.isAvailable().then((available: boolean) =>{
              if(available) {
                  let email = {
                    to: '[email protected]',
                    subject: this.register.value.subject,
                    body: 'De: ' + this.register.value.name + '<br>E-mail:' + this.register.value.email + '<br>Mensagem: ' + this.register.value.message,
                    isHtml: true
                  };

                  EmailComposer.open(email);
              }
          });
      }

using in form this:

(ngSubmit)="sendEmail()"


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

isAvailable is always false on iOS 10

Testing on an actual iPad with iOS 10.0.2 and an email client configured (Google Inbox), and isAvailable is always false.

Ignoring that and attempting to use "cordova.plugins.email.open" anyway doesn't do anything.

Thanks!

mimeType must not be nil.

Plugin 1.1.0, ios 9.3.2.

Works fine on Android, but on iOS my app simply crashes. I debug it in XCode and get the following error:

*** Assertion failure in - [MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/MessageUI/MessageUI-1637.33/Mail/MFMailComposeInternalViewController.m:746
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] mimeType must not be nil.'.

Is there a way to set a mimeType in this Plugin? I tried pre-pending "application/octet-stream:" to the filename, but that just crashed with an exception about the file being nil.

Please help.

Thanks,
Edward

issue with sending Attached Email

Hey ,
i was trying to create a csv file using Cordova Plugin file , and send it using Email Composer , unfortunately i didnt succeed to make it work !
let email = { to: '[email protected]', attachments: [fileURI], subject: "Subject", body: "Tatata", isHtml: true }; this.emailComposer.open(email);
Log:
2017-05-16 10:34:07.983915+0100 AppTech[7192:2804658] Start Creating file ///////// 2017-05-16 10:34:07.988542+0100 AppTech[7192:2804658] Finish Writing file 2017-05-16 10:34:07.988634+0100 AppTech[7192:2804658] Start Email Composer ///////// 2017-05-16 10:34:07.988685+0100 AppTech[7192:2804658] File in the attatchment: 2017-05-16 10:34:07.988731+0100 AppTech[7192:2804658] Start Email Composer 2017-05-16 10:34:07.991759+0100 AppTech[7192:2804658] End Email Composer 2017-05-16 10:34:07.999414+0100 AppTech[7192:2804711] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles 2017-05-16 10:34:08.000046+0100 AppTech[7192:2804711] [MC] Filtering mail sheet accounts for bundle ID: com.ionicframework.pharma974580, source account management: 1 2017-05-16 10:34:08.034734+0100 AppTech[7192:2804711] [MC] Result: YES 2017-05-16 10:34:08.035590+0100 AppTech[7192:2804658] [MC] Filtering mail sheet accounts for bundle ID: com.ionicframework.app299580, source account management: 1 2017-05-16 10:34:08.037174+0100 AppTech[7192:2804658] [MC] Result: YES 2017-05-16 10:34:08.089446+0100 AppTech[7192:2804658] File not found: 2017-05-16 10:34:08.099175+0100 AppTech[7192:2804658] *** Assertion failure in -[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/MessageUI/MessageUI-1770.3.19/Mail/MFMailComposeInternalViewController.m:744 2017-05-16 10:34:08.103901+0100 AppTech[7192:2804658] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[MFMailComposeInternalViewController addAttachmentData:mimeType:fileName:] attachment must not be nil.' *** First throw call stack: (0x18796afd8 0x1863cc538 0x18796aeac 0x188402710 0x19451585c 0x1001a419c 0x1001a3170 0x1001a25ac 0x100381a50 0x100381a10 0x100386b78 0x1879190c0 0x187916cdc 0x187846d94 0x1892b0074 0x18daff130 0x100017418 0x18685559c)

Any help please?


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Plugin crashes when checking availability

2016-01-07 14 53 45

my code:

$scope.goToStatistics = function (){
    if (window.cordova) {
        cordova.plugins.email.isAvailable(function (isAvailable) {
            console.log(isAvailable);
        });
    }
};

I tried to wrap it in $ionicPlatform.ready(), but nothing changed
Everything is ok, when I put plugin method in app.run()

.run(function ($ionicPlatform) {
    $ionicPlatform.ready(function() {
        cordova.plugins.email.isAvailable(function (isAvailable) {
            console.log(isAvailable);
        });
    });
})

Ionic 1.2.1
Cordova 5.4.1
cordova-ios 4.0.1

Many (odd) choices found in the picker on Android

Hello,

While testing on an S8 and an HTC G5 I noticed that the choices offered included functional, yet non-sensical offerings, such as bluetooth, Android Beam, and AT&T Locker.

I'm betting each of these registered as email apps, hence the reason they show up, and I would bet there's nothing the plugin can do about it. But, I thought I'd ask just in case there's something I'm missing.

Thanks,
John


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Integration tests

--- Want to back this issue? **[Post a bounty on it!](https://www.bountysource.com/issues/12391802-integration-tests?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github)** We accept bounties via [Bountysource](https://www.bountysource.com/?utm_campaign=plugin&utm_content=tracker%2F12875371&utm_medium=issues&utm_source=github).

please help

first > how can configured email account tto send emails

  • email not send. no alert no dismissed show i dont know why?

cordova.plugins.email.open({
to:['[email protected]'], // email addresses for TO field
subject:"hi" , // subject of the email
body:"test...", // email body (for HTML, set isHtml to true)
isHtml:true, // indicats if the body is HTML or plain text
}, function(){
alert('email view dismissed');
}, this);

}

i test on real device

Specify email app not working

Hi Team,

Specify Email App is not working and skype , Galery vault, Shareit opens in the email apps list.
Tested in android device with below specification 👍
Android Version : 5.0.2
Device : Lenovo A6000 Plus

Thank you in advance for any help regarding this!

needs a success callback

This has a feature to let you know if the user cancelled the email, but what about a success call back that says the email was actually sent? Is there anyway to determine that?

Reason: in my app email form, I need to know if the email was sent so I can post a message "Email Sent" and then clear out the form. Currently, the email sends and drops the user back into my app on the form that doesn't appear to have sent.

Something like:
cordova.plugins.email.open(preferences,success,fail) ;

or:

cordova.plugins.email.open({
   to: [addresses],
   subject: "blah"
   body: "more blah",
   isHtml: 0,
   success: externalSuccess();
}, function() { console.log("Email Cancelled")}

Is there already a solution for this?

What is the this in:

cordova.plugins.email.open(properties, function () {
    console.log('email view dismissed');
}, this);

Error in ./MyApp class MyApp - inline template:18:0 caused by: No provider for EmailComposer!

Create a ionic v2 new project.
ionic start TechAssist2 sidemenu --v2

Add the following line to page1.ts
import { EmailComposer } from '@ionic-native/email-composer';

Import the Email Composer
constructor(public navCtrl: NavController,private emailComposer: EmailComposer) {}

Get the following error on the webpage.
Error in ./MyApp class MyApp - inline template:18:0 caused by: No provider for EmailComposer!

screen shot 2017-04-03 at 1 25 00 pm

Ionic Framework: 2.3.0
Ionic App Scripts: 1.1.4

Angular Core: 2.4.8
Angular Compiler CLI: 2.4.8
Node: 6.10.1
OS Platform: macOS Sierra
Navigator Platform: MacIntel
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:52.0) Gecko/20100101 Firefox/52.0

Doesn't work?

Hi,

I used to use the katzer version of this plugin, but I can't get it to work (and it looks like it was a while since it was last updated!). I'm trying to work out why this won't work for me:

Uncaught TypeError: undefined is not a function

I'm calling it with this in config.xml:

<plugin spec="https://github.com/hypery2k/cordova-email-plugin" source="git" />

I see the file in the "assets" folder in the APK, so I'm a bit confused as to what I'm doing wrong?

Thanks

Andy

Error open

always appears "email view dismissed" both android and in ios and does not open.

Tag for version 1.2.1 points to wrong commit

I just installed 1.2.1 through npm with

$ cordova plugin add cordova-plugin-email --save

and got in config.xml.

<plugin name="cordova-plugin-email" spec="~1.2.1">

But when I started my app and used open nothing happened. I debugged the app and found out, that the fix you added in this commit was not in my plugin code.

Therefore I checked the repository tagging and saw that the master compared to the tag 1.2.1 has this small but important difference.

I think this an issue between the github release and the repository tag. Npm uses the repository tag and therefore is getting the old version, as I did.

There is a workaround for everyone else running into this. Just use the commit hash in config.xml until this is fixed:

<plugin name="cordova-plugin-email" spec="https://github.com/hypery2k/cordova-email-plugin.git#01596a9bec04d92f5ebfffd1e72cca486bfd94e4" />

Keep up the good work!

Pick title

Is it possible to set a custom text to that pick title "Open with" ?

isAvailable does not call callback on unsupported platform

cordova.plugins.email.isAvailable(foo) never calls foo on an unsupported platfrom (e.g. browser). I suggest to call the callback with false if exec() fails.

exports.isAvailable = function (callback, scope) {
    var fn = this.createCallbackFn(callback, scope);

    exec(fn, function () { fn(false); }, 'EmailComposer', 'isAvailable', []);
};

cordova 5.3.3
cordova-plugin-email 1.0.0

Android: cordova.plugins.email.isAvailable always false

I have updated the plugin to v 1.2.1 for a project and it seems like cordova.plugins.email.isAvailable always returns false. I do have a mail app installed and setup. The app is called "boxer" which seems to be the default mail client on Cyanogen 13.1.2 which I'm using. I'm using the following code:

cordova.plugins.email.isAvailable(
	function(isAvailable) {
		if(isAvailable) {
			//do something with cordova.plugins.email.open				
		}else{
			//alert no email available				
		}
	}
);

Could this be related to the issue #23 and #25 ?

PDF/png attachments with Gmail

Hi, I´m trying to send an email with a pdf attachment on Android 5.1.1 with Gmail but it doesn't work. Gmail tells me it cannot attach an empty file so I trying with a simple png. This is the code I´m using:

let filename = 'icon.png';
let img64 = 'iVBORw0KGgoAAAANSUhEUgAAAEgAAABICAIAAADajyQQAAA...'
let email = {
to: 'To email',
attachments: [
'base64:' + filename + '//' + img64,
],
subject: 'Subject',
isHtml: true
};
cordova.plugins.email.open(email);

The code opens Gmail correctly and fills all the fields, but it prompts a message telling me that it can not attach an empty file.

I don´t want the app saves the file into the device storage. I´m missing something?

Thanks in advance.

WP8.1 - Attachment [Feature/Bug]

Hello!
Is it possible to attach an file on Windows Phone 8.1?
In Android this works (tested already).
I've tested it on Windows Phone 8.1 but it doesn't attach the file.
(The changelog says its possible?)

The attachment on my side looks like:

var attachments = [];
var utf8_to_b64 = function (str) {
    return window.btoa(unescape(encodeURIComponent(str)));
};
var data = "base64:attachmentfile.html//" + utf8_to_b64(content);

attachments.push(data);

cordova.plugins.email.open({
        to: [], // email addresses for TO field
        cc: [], // email addresses for CC field
        bcc: [], // email addresses for BCC field
        attachments: attachments,
        subject: "Subject"
        body: "", // email body (for HTML, set isHtml to true)
        isHtml: false, // indicats if the body is HTML or plain text
    },
    function () {

    });

Any idea?

The E-Mail opens and the subject exists, but the attachment isn't available.

Greetings & Thanks
Graphefruit

Email composer causing blank white page

after added
$ ionic plugin add cordova-plugin-email
$ npm install --save @ionic-native/email-composer

Application is not launching, only splash screen white blank page is showing.

Getting below message in browser console -

SCRIPT5022: Cannot find module "@ionic-native/core"
main.js (100475,1)


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Add it to my ionic 2 project:

$ ionic plugin add cordova-plugin-email
$ npm install --save @ionic-native/email-composer

import it fine

import { EmailComposer } from '@ionic-native/email-composer';

add it to the constructor

private emailComposer: EmailCompose

And then I get the error:

/iphone/Macquarie/gpstracker-master/node_modules/@ionic-native/email-composer/index.js:10
import { Injectable } from '@angular/core';
^
ParseError: 'import' and 'export' may appear only with 'sourceType: module'

Android: html is stripped out of body

I'm testing this plugin with android and everything seems to be working except for html in the body of the email.

I'm using Cordova 6.5.0 with android platform version 6.1.1 and the latest version of the plugin. I'm testing on an android 7.0 device.

I've tested common tags like h1, a, i, b and br. Oddly, br is the only one that works and it properly adds line breaks.

I've tested with the Gmail and Inbox apps.

Installation instructions

The README says that in order to install the plugin we have to run

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

Is this correct? It's pointing to another repo.

HTML errors on Android

Hi,

Html email are not formatted anymore.
Do you also have this issue ?

For example, I changed in EmailComposerImpl.java

private void setBody (String body, Boolean isHTML, Intent draft) {
        CharSequence text = isHTML ? Html.fromHtml(body) : 
        //draft.putExtra(Intent.EXTRA_TEXT, text);
        draft.putExtra(Intent.EXTRA_TEXT, Html.fromHtml("<p><b>TEST</b></p>"));
}

Result

cordovapluginemail

Env

Android 5.0

$ cordova -v
6.5.0

===== plugins =====
cordova-plugin-compat 1.1.0 "Compat"
cordova-plugin-crosswalk-webview 2.3.0 "Crosswalk WebView Engine"
cordova-plugin-email 1.2.6 "EmailComposer"
cordova-plugin-file 4.3.1 "File"
cordova-plugin-geolocation 2.4.1 "Geolocation"
cordova-plugin-network-information 1.3.1 "Network Information"
cordova-plugin-splashscreen 4.0.1 "Splashscreen"
cordova-plugin-statusbar 2.2.1 "StatusBar"
cordova-plugin-whitelist 1.3.1 "Whitelist"
cordova-universal-clipboard 0.1.0 "Clipboard"
ionic-plugin-keyboard 2.2.1 "Keyboard"

===== platforms =====
Installed platforms:
  android 6.1.2

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

Unable to open email composer in device.

isAvailable is false. But I have Gmail app in device.
email.open is not working

In iOS, im unable to open composer. How to resolve in iOS ?
What does urischema mean ?

It doesn't set the body on the mail app in android.

When I set pre-defined body, it works on ios but not on android.
Here's my code:
EmailComposer.isAvailable().then((available: boolean) =>{
let email = {
app: 'mailto',
subject: this.card.title,
body: this.card.toHtml(true),
isHtml: true
};
EmailComposer.open(email).then((value) => {
console.log("Success:" + value);
}).catch((reason) => {
console.log("Fail:" + reason);
});
}).catch(reason => {
console.log(reason);
});

Note that I am using Ionic2 framework.
Please help me to solve this problem.
Thanks.

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.