# Email

You can launch the Email application to the compose view and optionally pre-populate the fields with the recipient's addresses, subject, body, and attachments.

There are two ways to launch the Email application to the compose view:

- Using a standard "mailto:" URI
- Pre-populating the fields of the view with the recipient's addresses, subject, body, and attachments.

(Note that you can also launch the Email application into the default view using the "launch" method. See the Services sample code for an example.)

## Objects

This section describes the following objects:

- params
- recipient

### params

Attribute | Type | Description
--- | --- | ---
account | integer | Optional. The ID of the account from which to send the email. If not specified, the default account is used. You can retrieve a list of accounts by using the accountList Account API.
attachments | array | Optional. Array of the objects containing the property fullPath (the full path and file name) and the optional properties displayName and mimeType.
recipients | array | Optional. An array of recipient objects.
summary | string | Optional. Text to display in the subject line.
text | string | Optional. Text to display in the body of the email.

### recipient (object literal)

Attribute | Type | Description
--- | --- | ---
contactDisplay | string | Optional. Display name for the recipient.
role | integer | Optional. Numeric ID for the type of recipient, where: 1 = To 2 = CC 3 = BCC
type | string | Optional. Set to "email".
value | string | A properly formed email address of the recipient.

## Methods

This section describes the following methods:

- open, Using mailto
- open, Using Parameter Hash

### open, Using mailto

Launches the Email application to the compose view with a "mailto:" URI.

Required parameter:

- target

#### Parameters

Parameter | Type | Description
--- | --- | ---
target | string | A "mailto:" URI formatted as specified in RFC2368.

#### Return Handling

There are no attributes for return handling.

#### Example

>     this.controller.serviceRequest("palm://com.palm.applicationManager", {
>       method:"open",
>       parameters:{
>           target: "mailto: address@email.com"
>       }
>     });

### open, Using Parameter Hash

Launches the Email application to the compose view with parameters hash.

Required parameters:

- id
- params

#### Parameters

Parameter | Type | Description
--- | --- | ---
id | string | Set to "com.palm.app.email".
params | object | Parameter information. See the params objects.

#### Return Handling

There are no attributes for return handling.

#### Example

>     this.controller.serviceRequest(
>       "palm://com.palm.applicationManager", {
>           method: 'open',
>           parameters: {
>               id: "com.palm.app.email",
>               params: {
>                   summary: "test subject",
>                   text: "Test email text.",
>                   recipients: [{
>                       type:"email",
>                       role:1,
>                       value:"address@email.com",
>                       contactDisplay:"Your name"
>                   }]
>               }
>           }
>       }
>     );

## Sample Code

See Services Sample.