日期:2014-05-20 浏览次数:20740 次
public void sendSMS(String mobilePhones, String content) throws GatewayException {
//服务
Service srv;
//输出消息对象
OutboundMessage msg;
//通知类对象
//OutboundNotification outboundNotification = new OutboundNotification();
srv = new Service();
//网关
SerialModemGateway gateway = new SerialModemGateway("modem.com7", "COM7", 9600, "wavecom", "");
//收件箱
gateway.setInbound(true);
//发件箱
gateway.setOutbound(true);
//ping码
gateway.setSimPin("0000");
srv.addGateway(gateway);
try {
//服务启动
srv.startService();
//发件箱信息
msg = new OutboundMessage(mobilePhones, content);
msg.setEncoding(MessageEncodings.ENCUCS2); // 中文
//真正发送消息
srv.sendMessage(msg);
srv.stopService();
} catch (Exception e) {
e.printStackTrace();