# Titanium.UI.EmailDialog

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

Availability
0.8
0.8
9.2.0

# Overview

Android iOS Windows
Android iOS Windows

The Email Dialog is created with the Titanium.UI.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.

# Examples

# Simple Email Dialog with Attachment

Create and send an email with a file attachment.

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

# Properties

# barColor

Availability
0.8
9.2.0
barColor :String | Titanium.UI.Color

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.


# bccRecipients

Availability
0.8
0.8
9.2.0
bccRecipients :Array<String>

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


# ccRecipients

Availability
0.8
0.8
9.2.0
ccRecipients :Array<String>

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


# html

Availability
0.8
0.8
9.2.0
html :Boolean

Determines whether the email message, specifically the contents of messageBody, should be sent as HTML content type rather than plain text.

Default: false


# messageBody

Availability
0.8
0.8
9.2.0
messageBody :String

Email message body.


# subject

Availability
0.8
0.8
9.2.0
subject :String

Subject line for the email.


# toRecipients

Availability
0.8
0.8
9.2.0
toRecipients :Array<String>

Recipients of the email included via the main TO field.

# Methods

# addAttachment

Availability
0.8
0.8
9.2.0
addAttachment(attachment) void

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

Name Type Description
attachment Titanium.Blob | Titanium.Filesystem.File

Attachment to include in the email.

Returns

Type
void

# isSupported

Availability
0.8
0.8
9.2.0
isSupported() Boolean

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

Type
Boolean

# open

Availability
0.8
0.8
9.2.0
open([options]) void

Opens this email dialog.

Parameters

Name Type Description
options AnimatedOptions

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 is false)

Returns

Type
void

# Events

# complete

Availability
0.8
0.8
9.2.0

Fired when this email dialog has completed sending an email.

Properties

Name Type Description
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.

source Object

Source object that fired the event.

type String

Name of the event fired.

bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

# Constants

# CANCELLED

Availability
0.8
9.2.0
CANCELLED :Number

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


# FAILED

Availability
0.8
0.8
9.2.0
FAILED :Number

Constant for the FAILED status result.


# SAVED

Availability
0.8
0.8
9.2.0
SAVED :Number

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


# SENT

Availability
0.8
0.8
9.2.0
SENT :Number

Constant for the SENT status result.