Send an email message to BlackBerry devices

To send an email message message to multiple BlackBerry® devices, you can use the multi-object sendMessageToUsers() method. To send a message to one user's BlackBerry device, you can use the single-object sendMessageToUsers() method.
Before you begin: Retrieve the following variables:
  • messageSubject string for the subject of the message that you want to send
  • messageBody string for the body of the message that you want to send
  • userIDs integers for the IDs of the user accounts that you want to send the message to
  1. Create the message object.
    UserMessage message=new UserMessage();
    message.setSubject(messageSubject);
    message.setBody(messageBody);
  2. Specify the type of message your want to send. To send an email message, use the EmailCommonMessageTypeEnumType.EMAIL enumeration value.
    EmailCommonMessageTypeEnum messageType=new EmailCommonMessageTypeEnum();
    messageType.setEnum(EmailCommonMessageTypeEnumType.EMAIL);
    
  3. Invoke sendMessageToUsers() method.
    SendMessageToUsersResult result=coreWebService.sendMessageToUsers(userIDs, message, messageType);
    
  4. Check the result for errors and handle any errors.
    if (result.getSendMessageToUsersReturnStatus().getCode()!= SendMessageToUserReturnStatusEnumType.SUCCESS) 
    {
        // handle any errors
    }
Next topic: Managing policies

Was this information helpful? Send us your comments.