You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* [Check for availability](#check-for-availability)
8
+
* [Compose an email](#compose-an-email)
9
+
* [Usage with Angular](#usage-with-angular)
10
+
*[API](#api)
11
+
* [Functions](#functions)
12
+
* [ComposeOptions](#composeoptions)
13
+
*[Known issues](#known-issues)
14
+
15
+
## Intro
16
+
17
+
A plugin to compose an e-mail, have the user edit the draft manually and send it.
18
+
19
+
> **Note:** This plugin depends on the default mail app. If you want a fallback to a third party client app like Gmail or Outlook, then check for availability, and if not available use a solution like [the Social Share plugin](https://github.com/tjvantoll/nativescript-social-share).
You can use this plugin to compose an e-mail, have the user edit the draft manually, and send it.
11
-
12
-
> **Note:** This plugin depends on the default mail app. If you want a fallback to a third party client app like Gmail or Outlook, then check for availability, and if not available use a solution like [the Social Share plugin](https://github.com/tjvantoll/nativescript-social-share).
13
-
14
28
## Installation
15
29
30
+
To install the plugin, run the following command in the root directory of your project:
31
+
16
32
```cli
17
33
npm install @nativescript/email
18
34
```
19
35
20
-
## Usage
21
-
### Importing
22
-
Once you've installed the plugin, the next step is to import it before using it.
To check if the device has a mail app installed, call the `available` method.
40
+
To check if the device has the Mail app installed, call the `available` method.
34
41
35
42
```ts
36
-
email.available().then((avail:boolean) => {
43
+
import { available() } from'@nativescript/email';
44
+
45
+
available().then((avail:boolean) => {
37
46
console.log('Email available? '+avail);
38
47
});
39
48
```
40
-
### Composing an email
49
+
### Compose an email
50
+
41
51
To compose an email, use the `compose` method.
42
52
43
53
```js
44
-
// let's first create a File object
54
+
import { compose } from'@nativescript/email';
55
+
56
+
// first create a File object
45
57
import { knownFolders } from'@nativescript/core';
46
58
var appPath =knownFolders.currentApp().path;
47
59
var logoPath = appPath +'/res/telerik-logo.png';
48
60
49
-
email
50
-
.compose({
61
+
compose({
51
62
subject:'Yo',
52
63
body:'Hello <strong>dude</strong> :)',
53
64
to: ['eddyverbruggen@gmail.com', 'to@person2.com'],
@@ -82,15 +93,19 @@ email
82
93
|`available()`|`Promise<boolean>`| Checks for availability of a mail app.|
83
94
|`compose(options: ComposeOptions)`|`Promise<boolean>`| Composes and sends a [ComposeOptions](#composeoptions) email.|
84
95
85
-
### Attachment
96
+
### Usage with Angular
86
97
87
-
| Name | Type | Description |
98
+
Check out [this tutorial (YouTube)](https://www.youtube.com/watch?v=fSnQb9-Gtdk) to learn how to use this plugin in a NativeScript-Angular app.
99
+
100
+
## API
101
+
### Functions
102
+
| Function | Return Type | Description |
88
103
|------|------|-------------|
89
-
|`fileName`|`string`| The name used for the attachment.<br>Example: fileName: 'Cute-Kitten.png'|
90
-
|`path`|`string`| The to the file to be attached. |
91
-
|`mimeType`|`string`| (`iOS-only`)Used to help the iOS device figure out how to send the file.Example:mimeType: 'image/png'|
104
+
|`available()`|`Promise<boolean>`| Checks for availability of a mail app.|
105
+
|`compose(options: ComposeOptions)`|`Promise<boolean>`| Composes and sends a [ComposeOptions](#composeoptions) email.|
92
106
93
107
### ComposeOptions
108
+
94
109
| Name | Type | Description |
95
110
|------|------|-------------|
96
111
|`subject`|`string`|_Optional_: The subject of the email.|
@@ -103,14 +118,18 @@ email
103
118
|`iosViewController`|`any`|_Optional_: (`iOS-only`) iOS View Controller to open `compose` from.|
104
119
105
120
106
-
## Usage with Angular
121
+
#### Attachment
122
+
123
+
| Name | Type | Description |
124
+
|------|------|-------------|
125
+
|`fileName`|`string`| The name used for the attachment.<br>Example: fileName: 'Cute-Kitten.png'|
126
+
|`path`|`string`| The to the file to be attached. |
127
+
|`mimeType`|`string`| (`iOS-only`)Used to help the iOS device figure out how to send the file.Example:mimeType: 'image/png'|
107
128
108
-
Check out [this tutorial (YouTube)](https://www.youtube.com/watch?v=fSnQb9-Gtdk) to learn how to use this plugin in a NativeScript-Angular app.
109
129
110
130
## Known issues
111
131
112
-
On iOS you can't use the simulator to test the plugin because of an iOS limitation.
113
-
To prevent a crash, this plugin returns `false` when `available` is invoked on the iOS simulator.
132
+
- 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 simulator.
0 commit comments