Giter Site home page Giter Site logo

vip-git / nativescript-email Goto Github PK

View Code? Open in Web Editor NEW

This project forked from eddyverbruggen/nativescript-email

0.0 2.0 0.0 33 KB

:envelope: NativeScript Email plugin, for composing and sending drafts

License: MIT License

JavaScript 100.00%

nativescript-email's Introduction

NativeScript Email

An Email plugin for use in your NativeScript app.

You can use it to compose emails, edit the draft manually, and send it.

Installation

Make sure you're running NativeScript 2.3.0 or up. Do npm install -g nativescript if not.

The run the following command from the root of your project:

tns plugin add nativescript-email

API

To use this plugin you must first require/import it:

TypeScript

import * as email from "nativescript-email";
// or
import { compose } from "nativescript-email";
// or even
import { compose as composeEmail } from "nativescript-email";

JavaScript

var email = require("nativescript-email");

available

TypeScript

  email.available((avail: boolean) => {
      console.log("Email available? " + avail);
  })

JavaScript

  email.available().then(function(avail) {
      console.log("Email available? " + avail);
  })

compose

JavaScript

  // let's first create a File object using the tns file module
  var fs = require("file-system");
  var appPath = fs.knownFolders.currentApp().path;
  var logoPath = appPath + "/res/telerik-logo.png";

  email.compose({
      subject: "Yo",
      body: "Hello <strong>dude</strong> :)",
      to: ['[email protected]', '[email protected]'],
      cc: ['[email protected]'],
      bcc: ['[email protected]', '[email protected]'],
      attachments: [
        {
            fileName: 'arrow1.png',
            path: 'base64://iVBORw0KGgoAAAANSUhEUgAAABYAAAAoCAYAAAD6xArmAAAACXBIWXMAABYlAAAWJQFJUiTwAAAAHGlET1QAAAACAAAAAAAAABQAAAAoAAAAFAAAABQAAAB5EsHiAAAAAEVJREFUSA1iYKAimDhxYjwIU9FIBgaQgZMmTfoPwlOmTJGniuHIhlLNxaOGwiNqNEypkwlGk9RokoIUfaM5ijo5Clh9AAAAAP//ksWFvgAAAEFJREFUY5g4cWL8pEmT/oMwiM1ATTBqONbQHA2W0WDBGgJYBUdTy2iwYA0BrILDI7VMmTJFHqv3yBUEBQsIg/QDAJNpcv6v+k1ZAAAAAElFTkSuQmCC',
            mimeType: 'image/png'
        },
        {
            fileName: 'telerik-logo.png',
            path: logoPath,
            mimeType: 'image/png'
      }],
      appPickerTitle: 'Compose with..' // for Android, default: 'Open with..'
  }).then(
    function() {
      console.log("Email composer closed");
    }, function(err) {
      console.log("Error: " + err);
    });

Full attachment support has been added to 1.3.0 per the example above.

Since 1.4.0 the promise will be rejected in case a file can't be found.

Usage with Angular

Check out this tutorial (YouTube) to learn how to use this plugin in a NativeScript-Angular app.

Known issues

On iOS you can't use the simulator to test the plugin because of an iOS limitation. To prevent a crash this plugin returns false when available is invoked on the iOS sim.

nativescript-email's People

Contributors

bradmartin avatar eddyverbruggen avatar

Watchers

 avatar  avatar

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.