代码之家  ›  专栏  ›  技术社区  ›  Tauqeer Shah

用VB6从pc向移动设备发送长消息

  •  3
  • Tauqeer Shah  · 技术社区  · 9 年前

    我想从电脑向手机发送长短信(超过160个字符)。我在VB6中使用MSComm控件。它对小消息很有效,但当我的消息超过160个字符时,它显示发送正常,但消息未送达。

    With MSComm1
        .CommPort = port
        .Settings = "9600,N,8,1"
        .Handshaking = comRTS
        .RTSEnable = True
        .DTREnable = True
        .RThreshold = 1
        .SThreshold = 1
        .InputMode = comInputModeText
        .InputLen = 0
        .PortOpen = True 'must be the last
    End With
    
    'Send an 'AT' command to the phone
    MSComm1.Output = "AT" & vbCrLf
    Sleep 500
    MSComm1.Output = "AT+CMGF=1" & vbCrLf 'This line can be removed if your modem will always be in Text Mode...
    Sleep 500
    MSComm1.Output = "AT+CMGS=" & Chr(34) & mnumber & Chr(34) & vbCrLf  'Replace this with your mobile Phone's No.
    Sleep 1000
    MSComm1.Output = TxtMessage.Text & Chr(26)
    
    1 回复  |  直到 9 年前
        1
  •  4
  •   Alex K.    9 年前

    您不能发送超过160个字符限制的邮件。

    当你的手机收到一条长消息时,它实际上会收到多条消息并将它们拼接在一起,这就是所谓的 串联短信 .

    为此,您需要从 文本模式 (您当前如何与设备交互) 可编程逻辑单元 模式这使您能够手动设置SMS消息头(UDH)。

    在UDH中,您可以设置一个标志(IEI),指示消息是连接的SMS、部件总数和当前部件号。然后,您可以发送多条短信,并依靠接收端将它们粘在一起。

    推荐文章