# Titanium.UI.EmailDialog

> An email dialog is a modal window that allows users to compose and send an email.

- Source: https://titaniumsdk.com/docs/sdk/13.4.0/Titanium.UI.EmailDialog
- Titanium SDK version: 13.4.0
- Kind: view
- Platforms: Android, iPhone, iPad, macOS
- Since: Titanium SDK 0.8
- Extends: Titanium.UI.View
- Inheritance: Titanium.UI.View > Titanium.Proxy

| Android | iOS |
| ------- | --- |
| ![Android](./emaildialog_android.png) | ![iOS](./emaildialog_ios.png) |

The Email Dialog is created with the [Titanium.UI.createEmailDialog](https://titaniumsdk.com/docs/sdk/Titanium.UI.md#createEmailDialog) method. The user needs to
register an e-mail account on the device in order to open the dialog.  The dialog will not
open when there is not a registered e-mail account.

**iOS Platform Notes**

On iOS, you cannot test the e-mail dialog on the iOS Simulator. Test the email dialog on device.

## Example: Simple Email Dialog with Attachment

Create and send an email with a file attachment.

``` js
var emailDialog = Ti.UI.createEmailDialog()
emailDialog.subject = "Hello from Titanium";
emailDialog.toRecipients = ['foo@yahoo.com'];
emailDialog.messageBody = '<b>Titanium SDK Rocks!</b>';
var f = Ti.Filesystem.getFile('cricket.wav');
emailDialog.addAttachment(f);
emailDialog.open();
```

## Properties

### barColor

- Type: String | Titanium.UI.Color
- Platforms: iPhone, iPad, macOS

Bar color of the email dialog window, as a color name or hex triplet.

For information about color values, see the "Colors" section of [Titanium.UI](https://titaniumsdk.com/docs/sdk/Titanium.UI.md).

### bccRecipients

- Type: Array<String>
- Platforms: Android, iPhone, iPad, macOS

Recipients of the email included via the `BCC` (Blind Carbon Copy) field.

### CANCELLED

- Type: Number
- Platforms: iPhone, iPad, macOS
- Permission: read-only

Constant for the `CANCELLED` status result. On Android, this property exists but is not used.

### ccRecipients

- Type: Array<String>
- Platforms: Android, iPhone, iPad, macOS

Recipients of the email included via the `CC` (Carbon Copy) field.

### FAILED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for the `FAILED` status result.

### html

- Type: Boolean
- Platforms: Android, iPhone, iPad, macOS
- Default: `false`

Determines whether the email message, specifically the contents of
[messageBody](https://titaniumsdk.com/docs/sdk/Titanium.UI.EmailDialog.md#messageBody), should be sent as HTML content type
rather than plain text.

### messageBody

- Type: String
- Platforms: Android, iPhone, iPad, macOS

Email message body.

### SAVED

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for the `SAVED` status result. On Android, this property exists but is not used.

### SENT

- Type: Number
- Platforms: Android, iPhone, iPad, macOS
- Permission: read-only

Constant for the `SENT` status result.

### subject

- Type: String
- Platforms: Android, iPhone, iPad, macOS

Subject line for the email.

### toRecipients

- Type: Array<String>
- Platforms: Android, iPhone, iPad, macOS

Recipients of the email included via the main `TO` field.

## Methods

### addAttachment

- Platforms: Android, iPhone, iPad, macOS

Adds an attachment.

On Android, multiple attachments may be added, but will only work if the user chooses to
send via the Android Gmail or K9 mail clients.

The Android "Mail" app, which is only available on some handsets, will only accept one
attachment from a Titanium app.

Parameters:

- `attachment` (Titanium.Blob | Titanium.Filesystem.File): Attachment to include in the email.

### isSupported

- Platforms: Android, iPhone, iPad, macOS

Indicates whether sending email is supported by the system.

On iOS 10, the user is able to uninstall the built-in applications including Mail. Because
of that, you should ensure to check if the email dialog is supported on the current device.

Returns: Boolean

### open

- Platforms: Android, iPhone, iPad, macOS

Opens this email dialog.

Parameters:

- `options` (AnimatedOptions, optional): Supported on iOS only. Simple object to override animation. Note that the default here is equivalent to passing in `{ animated: true }` (while typically the default for [AnimatedOptions](https://titaniumsdk.com/docs/sdk/AnimatedOptions.md) is false) Default: `{ animated: true }`.

## Events

### complete

- Platforms: Android, iPhone, iPad, macOS

Fired when this email dialog has completed sending an email.

Event properties:

- `success` (Boolean): Indicates if the email was handled successfully. Returns `true` if request succeeded, `false` otherwise. Note that emails being deleted or saved for later do count as success.
- `error` (String): Error message, if any returned. Will be undefined if `success` is `true`.
- `code` (Number): Error code. Error code will be 0 if `success` is `true`, nonzero otherwise. If the error was generated by the operating system, that system's error value is used. Otherwise, this value will be -1.
- `result` (Number): Status of the email send process. The `SAVED` and `CANCELLED` constants are iOS only. On Android, this property will return `SENT` when the user discards or saves a message.

## Inherited members

36 members are inherited. Each is documented on the type that declares it.

- [Titanium.Proxy](https://titaniumsdk.com/docs/sdk/13.4.0/Titanium.Proxy.md): `addEventListener`, `apiName`, `applyProperties`, `bubbleParent`, `fireEvent`, `lifecycleContainer`, `removeEventListener`
- [Titanium.UI.View](https://titaniumsdk.com/docs/sdk/13.4.0/Titanium.UI.View.md): `accessibilityDisableLongPress`, `clearMotionEffects`, `elevation`, `filterTouchesWhenObscured`, `getViewById`, `hiddenBehavior`, `hide`, `horizontalMotionEffect`, `id`, `insertAt`, `keepHardwareMode`, `previewContext`, `replaceAt`, `rotate`, `rotation`, `rotationX`, `rotationY`, `scaleX`, `scaleY`, `show`, `stopAnimation`, `tooltip`, `touchFeedback`, `touchFeedbackColor`, `transitionName`, `translationX`, `translationY`, `translationZ`, `verticalMotionEffect`

---

- This corpus documents Titanium SDK 13.4.1. Anything here that does not name a version describes 13.4.1.
- Titanium is maintained by TiDev. The Appcelerator toolchain is retired: there is no `appc` CLI, no Appcelerator Studio and no hosted build service. The supported CLI is `titanium` on npm, invoked as `ti`.

