调用SP.DLL类库中方法将信息发送到指定员工的手机中。
protected void imgBtnSend_Click(object sender, ImageClickEventArgs e)
{
//如果没有手机号码接收信息,则程序不继续执行。
if (txtAccepter.Text == "")
{
Response.Write(bc.MessageBox("手机号码不能为空!"));
return;
}
//获取短信猫的基本信息
string strCOM = GMS.GSMModemGetDevice(); //COM1
string strBTL = GMS.GSMModemGetBaudrate(); //波特率
string strMobileNo = GMS.GSMModemGetSnInfoNew(strCOM, strBTL); //机器号码
string strWarranty = "YIWU-IJDD-CDQW-JDWG"; //设备授权号(设备上自带)
string[] Accepters = txtAccepter.Text.Split(',');
//连接设备
if (GMS.GSMModemInitNew(strCOM, strBTL, null, null, false, strWarranty) == false)
{
Response.Write(bc.MessageBox("设备连接失败!" + GMS.GSMModemGetErrorMsg()));
return;
}
// 发送短信
if (Accepters.Length > 1)
{
for (int j = 0; j < Accepters.Length; j++)
if (GMS.GSMModemSMSsend(null, 8, txtInfo.Text, Encoding.Default.GetByteCount(txtInfo.Text), Accepters[j].ToString(), false) == true)
Response.Write(bc.MessageBox("短信发送成功!"));
else
Response.Write(bc.MessageBox("短信发送失败!"));
}
else
{
if (GMS.GSMModemSMSsend(null, 8, txtInfo.Text, Encoding.Default.GetByteCount(txtInfo.Text), txtAccepter.Text, false) == true)
Response.Write(bc.MessageBox("短信发送成功!"));
else
Response.Write(bc.MessageBox("短信发送失败!"));
}
}