Skip to content

Instantly share code, notes, and snippets.

@reflog
Created June 16, 2010 17:34
Show Gist options
  • Save reflog/440998 to your computer and use it in GitHub Desktop.
Save reflog/440998 to your computer and use it in GitHub Desktop.
public static boolean SendSMS(String phone, String text){
try {
String smsurl = "sms://+"+phone;
MessageConnection conn =
(MessageConnection)Connector.open(smsurl);
TextMessage msgOut = (TextMessage) conn.newMessage(MessageConnection.TEXT_MESSAGE);
msgOut.setPayloadText(text);
Utils.log("sending to "+smsurl);
conn.send(msgOut);
return true;
} catch (Throwable e) {
Utils.log("Cannot send sms: "+e + " msg: "+e.getMessage());
}
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment