已有一短信猫,测试已通过,现在如何实现让这个短信猫根据数据表里的手机号,自动发送短信.不可能我用手工去发送!
下面是是通过按钮Command3来发送的源码,现在我想让他自已通过判定表里是否有内容,然后自己动发送,
期待“zhengoodman”的用户朋友请来指导,其他高手们一起来探讨,谢谢
'发送短信
Private Sub Command3_Click()
        Dim n As Integer
        Dim strSQL As String
        Dim smscontent As String
        Dim number As String
        Dim smslen As Long
        Dim charset As String
        Dim ret, statereq As Boolean
        hm = Trim(jshm.text)
        nr = Trim(fsnr.text)
        sj = Trim(time.text)
        '0) 格式检查
       
        If jshm.text = "" Then
            MsgBox "手机号码不能为空!"
            jshm.SetFocus
            Exit Sub
        End If
        If fsnr.text = "" Then
            MsgBox "短信内容不能为空!"
            fsnr.SetFocus
            Exit Sub
        End If
       
        If sendstate.Value = 1 Then
            statereq = True
        Else
            statereq = False
        
       
        End If
        '2) 发送短信
        status1.text = "正在发送短信,请稍等 ......"
        
        smscontent = StrConv(fsnr.text, vbFormUnicode)
        smslen = LenB(StrConv(fsnr.text, vbFormUnicode))
        number = jshm.text
        
        ret = GSMModemSMSsend(Device.text, "", 0, smscontent, smslen, jshm.text, statereq)
       
        If ret Then
             
          '发送成功向已发信息表插入一条记录
         strSQL = "Insert Into 已发_信息表 (手机号,信息内容,发送时间)"
         strSQL = strSQL + " Values('" + hm + " ','" + nr + "','" + sj + "' )"
         ADOcn.Execute strSQL
         '同时删除待发信息表的记录
         strSQL = "delete from 待发_信息表 where 手机号='" + jshm.text + "' "
         ADOcn.Execute strSQL
            MsgBox "GSMModemSMSsend: 短信发送成功!"
       Else
      
            MsgBox "GSMModemSMSsend: 短信发送失败!" + GSMModemGetErrorMsg(Device.text)
                 
        End If
        
       
      '3) 显示信息
        cwxx.text = GSMModemGetErrorMsg(Device.text)
        status1.text = "发送短信完毕!."
        End Sub

解决方案 »

  1.   

    拖一个timer控件,时间设定一下,如30000,是30秒
    Timer1.Interval = 30000'定时执行
    Private Sub Timer1_Timer()
        Call Command1_Click
    End Sub
      

  2.   

    更正 Call Command1_Click
    为 Call Command3_Click
      

  3.   

    写一个job,
    检查数据表 待发_信息表 select county(*) 
    如果有数据,
    begin trans
      运行发送信息代码
      发送成功则 
        Insert Into 已发_信息表 (手机号,信息内容,发送时间)"
        delete from 待发_信息表 where
        commit trans
      发送失败
         rollback trans
        记录logjob放到计划任务中,几分钟跑一次
      

  4.   

    记录集循环发送
    For i = 1 To rs.RecordCount
      ......  
      rs.MoveNext
    next