0

hi guys i develop an application in vb6.0 sending to mobile # is fine but when i try to send two or more mobile # it will only send to the first # and the other is none. here is my code please take a look.

MSComm1.Output = "AT" & vbCrLf
                Sleep 100
                MSComm1.Output = "AT+CMGF=1" & vbCrLf
                Sleep 200

                MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpM_MobileNum & Chr(34) & vbCrLf
                Sleep 300

                MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpF_MobileNum & Chr(34) & vbCrLf
                Sleep 400

                MSComm1.Output = TMPMESEJ & Chr(26) & vbCrLf
                Sleep 500

i hope you can help me at this. Thank you

Denver Bomb
  • 13
  • 1
  • 5
  • I think it would be useful to see what the modem answered for each command. Are you getting anything error messages? Or is the modem answering OK for every command? – Matt Aldridge Jun 20 '14 at 05:37
  • yes sir the modem is answering and there is no error my problem for this is i cant send to tmpF_MobileNum, it will only send at tmpM_MobileNum. i dont know what to do. – Denver Bomb Jun 20 '14 at 11:41

1 Answers1

0

To send an SMS via a modem you are correct in using the AT+CMGS but I believe you are not following the syntax of the command correctly.

You need to send the following:

  1. AT+CMGS=<Mobile phone number><cr>
  2. <Message text><ctrl-Z>

You can only send one message at a time to one mobile phone number. And from what I can see your code is attempting to send multiple messages before trying to send the <ctrl-Z>

By the way is ascii character 26.

////////////////////////////////////////
// Send message to first mobile number
////////////////////////////////////////

MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpM_MobileNum & Chr(34) & vbCrLf
// Wait for answer from modem should return ">"

MSComm1.Output = "Test Message One" & Chr(26)
// Wait for answer to check if OK came back

////////////////////////////////////////
// Send message to second mobile number
////////////////////////////////////////

MSComm1.Output = "AT+CMGS=" & Chr(34) & tmpF_MobileNum & Chr(34) & vbCrLf
// Wait for answer from modem should return ">"

MSComm1.Output = "Test Message Two" & Chr(26)
// Wait for answer to check if OK came back
Matt Aldridge
  • 2,037
  • 16
  • 21
  • yes i want to send a message at a time to one mobile phone number but i need to send more than one mobile number with one message sir i hope it's clear though. how am i going to do that? i dont get it sir. can you edit the code i gave? i tried like this and i think this looks funny :( MSComm1.Output = "AT+CMGS=" & tmpM_MobileNum & Chr(34) & cr Sleep 300 List1.AddItem MSComm1.Input MSComm1.Output = "AT+CMGS=" & tmpF_MobileNum & Chr(34) & cr Sleep 400 List1.AddItem MSComm1.Input – Denver Bomb Jun 21 '14 at 09:52
  • I added some code to my answer. I am no VB expert but here I show how to send the right commands to the modem. What is missing is the handling of responses from the modem. Like I mentioned in my original answer you cannot send to multiple recipients. This is not how SMS works. You need to send a message one by one to each mobile number – Matt Aldridge Jun 21 '14 at 10:08
  • i get it sir before you post you code sir, i just search about AT+CMGS= and i see what are you trying to say to me. and very glad that we have the same code thank you. one thing i learn that after the mobile number is the text thats why. one thing sir whats the purpose of the sleep? – Denver Bomb Jun 21 '14 at 10:22
  • Depending on your modem you may need to use "sleep"'s. They usually recommend waiting a certain amount of time before executing another command depending on which command it is that you originally executed. Here it is best to double check with your modem manufacturers documentation. Generally waiting for a response I wouldn't use a sleep and rather would have a "reader" thread to process information coming back from the modem. – Matt Aldridge Jun 21 '14 at 12:35