I am looking for code to send SMS using J2ME.
You can try the code below to implement this:
private boolean SendSMS(String sPhoneNo, String sMessage) {
boolean result = true;
try {
String addr = "sms://" + sPhoneNo;
MessageConnection conn = (MessageConnection) Connector.open(addr);
TextMessage msg = (TextMessage)
conn.newMessage(MessageConnection.TEXT_MESSAGE);
msg.setPayloadText(sMessage);
conn.send(msg);
conn.close();
}
catch (SecurityException se) {
result = false;
}
catch (Exception e) {
result = false;
}
return result;
}
You can specify any special port by just adding ":port_no"
after:
"String addr = "sms://" + sPhoneNo"