try{
String[] addressees = {mobile number};
if (addressees != null)
{
mc = (MessageConnection)Connector.open("sms://");
TextMessage message = (TextMessage)mc.newMessage(MessageConnection.TEXT_MESSAGE, "sms://");
message.setPayloadText(msg);
for (int i = 0; i < addressees.length; i++)
{
if (addressees[i] != null)
{
message.setAddress("sms://" + addressees[i]);
mc.send(message);
}
}
mc.close();
}
}
catch (ConnectionNotFoundException ex)
{
System.out.println(ex.getMessage());
}
catch (IllegalArgumentException ex)
{
System.out.println("Ilegal Argument: " + ex.getMessage());
}
catch (SIMCardException ex)
{
System.out.println("SIMCard Exception: " + ex.getMessage());
}
catch (InterruptedIOException e)
{
System.out.println(e.getMessage());
}
catch (InterruptedException e)
{
System.out.println(e.getMessage());
}
catch (IOException e)
{
System.out.println(e.getMessage());
}
catch (NullPointerException e)
{
System.out.println(e.getMessage());
}
catch (SecurityException e)
{
System.out.println(e.getMessage());
}
No comments:
Post a Comment