6.8.6 Delete

Delete method is used to delete a message. It is available only in synchronous mode.

The following is an example for using Delete:

Synchronous

messaging_handle.call('Delete', {'MessageId': message_id})

The following table summarizes the specification of Delete:

Interface IMessaging
Description Delete deletes the message.
Response Model Synchronous
Pre-condition Valid instance of IMessaging interface is instantiated.
Post-condition Message no more exists in database.

Input Parameters

Input parameter specifies the MessageId of the message to delete.

Table 6.182: Input parameters for Delete
Name Type Range Description
MessageId 32 bit int MessageId Deletes message with the specified message ID.


Output Parameters

Output parameters contain ErrorCode, and ErrorMessage if the operation fails.

Table 6.183: Output parameters for Delete
Name Type Range (Type: string) Description
ErrorCode int NA Service specific error code on failure of the operation.
ErrorMessage string NA Error description in Engineering English.


Errors

The following table lists the error codes and their values:

Table 6.184: Error codes
Error code value Description
0 Success
1000 Invalid service argument
1002 Bad argument type
1003 Missing argument
1012 Item Not found


Error Messages

The following table lists the error messages and their description:


Table 6.185: Error messages
Error messages Description
Messaging:Delete:MessageId Type Invalid Specifies if the type of MessageId parameter is mismatched.
Messaging:Delete:MessageId Value Incorrect Specifies if the value of MessageId parameter is negative.
Messaging:Delete:MessageId Missing Specifies if the MessageId parameter is missing.
Messaging:Delete:Asynchronous Operation not supported Specifies if Delete is called asynchronously.


Example

The following sample code illustrates how to delete a particular SMS:

import scriptext
import appuifw
import e32

lock = e32.Ao_lock()
sms_iter = None
messaging_handle = scriptext.load('Service.Messaging', 'IMessaging')

sms_iter = messaging_handle.call('GetList', {'Type': u'Inbox'})

id_list = []
body_list = []
for sms_dict in sms_iter:
    if sms_dict['MessageType'] == 'SMS':
        id_list.append(sms_dict['MessageId'])
        body_list.append(sms_dict['BodyText'])

# Select the message to be deleted
message_index = appuifw.selection_list(body_list)
try:
    messaging_handle.call('Delete', {'MessageId': id_list[message_index]})
except scriptext.ScriptextError, err:
    print "Error deleting SMS :", err
else:
    print "Message deleted successfully"

See About this document... for information on suggesting changes.