读取短信

自动读取新短信

首先新建一个收件箱表,包括四列,分别是:发送时间、接收时间、号码、内容

然后将NewMessage事件代码设置为:

Dim r As Row = Tables("收件箱").AddNew()
r(
"号码") = e.FromNumber
r(
"内容") = e.Content
r(
"接收时间") = Date.Now
r(
"发送时间") = e.SentTime
r.Save()
FoxSms.DelMsgForIndex(e.Index)
'从SIM卡删除此短信

现在打开短信猫,短信猫即可自动将收到的新短信登记到收件箱表 ,并从SIM卡删除此短信。

读取现有短信

如果要读取SIM卡中的现有短信,可以使用下面的代码:

If FoxSMS.Ready = False Then
    MessageBox.show(
"请先连接短信猫!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information)
    Return
End
If
Dim cnt As Integer = FoxSMS.SimMsgCount
If
cnt > 0 Then '如果SIM卡有短信
    Dim
sendtime As String
    Dim
strFrom As String
    Dim
strContent As String
    Dim
result As Integer
   
FoxSMS.AutoDelMsg = True '自动从SIM卡删除已经读取的短信
   
Tables("收件箱").StopRedraw()
   
For Index As Integer = 1 To FoxSMS.SimMsgCapacity
        result = FoxSMS.ReadMsgForIndex(Index, strFrom, strContent, sendtime)

        If
result = 0 Then
            Dim
dr As Row = Tables("收件箱").AddNew()
            dr(
"号码") = strFrom
            dr(
"内容") = strContent
            dr(
"发送时间") = SendTime
            dr(
"接收时间") = Date.Now
        End
If
    Next
    Tables
("收件箱").DataTable.Save()
    Tables
("收件箱").ResumeRedraw()
End
If


本页地址:http://www.foxtable.com/webhelp/topics/2424.htm