To create engaging applications with various messaging features, you must learn to work with messages in the message store:
Retrieve messages whose sender is "me" from the message storage using the findMessages() method of the MessageStorage interface with a filter (for attributes supported in the filter, see Messaging Filter Attributes):
function serviceListCB(services) { smsService = services[0]; /* Set the attribute filter */ var filter = new webapis.AttributeFilter("from", "CONTAINS", "me"); smsService.messageStorage.findMessages(filter, messageArrayCB, errorCallback); }
The findMessages() method returns an array of Message objects as the search result.
The search result does not contain the actual bodies of the messages. To load a message body, call the loadMessageBody() method of the MessageService interface.
To update a message in the message storage, use the updateMessages() method. The method uses an array of Message objects found previously by the findMessages() method as a parameter.
In the following example, the isRead attribute of the first Message object in the given array is updated to true.
function messageArrayCB(messages) { messages[0].isRead = true; emailService.messageStorage.updateMessages(messages, successCallback, errorCallback); }
To delete a message from the message storage, use the removeMessages() method:
function messageArrayCB(messages) { smsService.messagingStorage.removeMessages(messages, successCallback, errorCallback); }