# Messaging

You can launch the Messaging application into the compose/chat view by passing in a JSON object containing parameters for that view. The supported parameters include: a contact ID, mobile number (SMS/MMS), JPEG photo attachment (MMS), and message to pre-populate the view.

## Object

This section describes the following object:

- Parameters

### Parameters

Attribute | Type | Description
--- | --- | ---
attachment | string | Optional. The file path to a single attachment file (JPEG).
composeRecipients | string | Optional. An alternative to using the personID or contactPointId. An array of JSON objects. Each object must contain an "address" object, which specifies either the target phone number or the target IM address. If an IM address is used, then the object must also contain a "serviceName" specifying the IM addressee's service. Valid service names are "yahoo", "gmail", and "aol".
contactPointId | string | Optional. Contact entry ID for the contact method (e.g., mobile phone number, IM address). This applies only to the launched chat view. Note: You can optionally pass a contactPointId to set the selected transport when you launch the chat.
messageText | string | Optional. The contents of the message.
personId | string | Optional. Contact ID for the recipient. This applies only to the launched chat view.

Note: The "composeAddress" attribute is deprecated, as it only allows the use of one phone number. Use the "composeRecipients" attribute instead.

## Method

This section describes the following method:

- launch

### launch

Launches the compose view by passing an address, message, or JPEG photo attachment with the specified data pre-populated in the view. Launches the chat view to a specific buddy by passing a contact ID.

Required parameters:

- id
- parameters

#### Parameters

Parameter | Type | Description
--- | --- | ---
id | string | Set to "com.palm.app.messaging".
parameters | object | See the parameters objects.

#### Return Handling

There are no attributes for return handling.

#### Example

In this example, the messaging service is called to launch the messaging application. The "To:" field is pre-filled with a Yahoo IM address for "Joe", and a phone number for a second recipient. The message text field is prefilled with "Text of the message".

>     this.controller.serviceRequest('palm://com.palm.applicationManager', {
>       method: 'launch',
>       parameters: {
>           id: 'com.palm.app.messaging',
>           params: {
>               composeRecipients: [
>                   {
>                       address: "joe",
>                       serviceName: "yahoo"
>                   },
>                   {
>                       address: "4085555555"
>                   }
>               ],
>               messageText: 'Text of the message'
>           }
>       },
>       onSuccess: this.handleOKResponse,
>       onFailure: this.handleErrResponse
>     });

## Sample Code

See Services Sample.