Sending SMS in GSM Network using BlackBerry
http://forum.gssdaily.com/viewtopic.php?f=36&t=1671
-
Code:
Select all
-
import javax.microedition.io.Connector;
import javax.wireless.messaging.MessageConnection;
import javax.wireless.messaging.TextMessage;
String addr = "sms://"+number;
MessageConnection conn = null;
try {
conn = (MessageConnection) Connector.open(addr);
//generate a new text message
TextMessage msgOut = (TextMessage)conn.newMessage(
MessageConnection.TEXT_MESSAGE);
msgOut.setPayloadText(message);
//finally send our message
conn.send(msgOut);
} catch(Exception e) {
System.out.println(e.toString());
} finally {
try {
conn.close();
conn = null;
} catch(Exception e){}
}