Question : Rewrite a VB script ( Visual Basic ) to send SMS message from another Telco SMS website

 
Currently I have a working VB script that could send SMS from a Telco's website (the codes
are shown below) which someone gave to me :


I would like to rewrite the codes below to send it via another Telco's website ie:
http://websms.starhub.com/websmsn/usr/createMsgSessionPageShow.do?method=initCreateSession

The adapted VB script will need to fill up 3 fields, ie
1)  "Your friend's Starhub Mobile number"
2)  "Your name" - this can be any name, let's assign it OpsDC
3)  "Message" : up to 140 characters of free text

Then click on the "Send" button, pause for 2 secs & then click on
"End SMS session".

The 1st attachment is the source text for the 1st screen (where we enter
   friend/destination mobile number, sender name & message

The 2nd attachment is the source text for the 2nd screen (where we'll
   need to click "End SMS session" button



strMobile = "97888888"
strMessage = "This is a test message"
 
Set objIE = CreateObject("InternetExplorer.Application")
 
objIE.Navigate "http://sms.singtel.com/internetsms/"
objIE.Visible = True

 
Do While objIE.Busy
      WScript.Sleep 2000
Loop

 
objIE.Document.LoginForm.Item("email").Value = "[email protected]"
objIE.Document.LoginForm.Item("password").Value = "mypasswd"
objIE.Document.LoginForm.submit

 
Do While objIE.Busy
      WScript.Sleep 2000
Loop

 
objIE.Document.startChatForm.Item("mobile").Value = strMobile
objIE.Document.getElementByID("submit").Click

 
WScript.Sleep 10000


strURL = "http://sms.singtel.com/internetsms/sendMsg.do?id=1&recipient="
intCounter = 0

Set objShell = CreateObject("Shell.Application")
Set objShellWindows = objShell.Windows

Do While intCount <= 10
      For each objWindow in objShellWindows
            If Instr(objWindow.LocationURL, strURL) Then
                  StrPopupURL = objWindow.LocationURL
                  Exit Do
            End If
      Next

      intCount = intCount + 1

      If intCount = 10 Then
            objIE.Navigate "http://sms.singtel.com/internetsms/logoutAction.do"
            WScript.Echo "The script was not able to find the popup window. Script Quitting"
            WScript.Quit
      End If

      Sleep 2000
Loop

Set objIE_Pop = CreateObject("InternetExplorer.Application")  

objIE_Pop.Navigate strPopupURL
objIE_Pop.Visible = True

 
Do While objIE_Pop.Busy
      WScript.Sleep 2000
Loop


objIE_Pop.Document.getElementByID("message").Value = strMessage
objIE_Pop.Document.getElementByID("submit").click


Do While objIE_Pop.Busy
 WScript.Sleep 2000
Loop


WScript.Sleep 10000


For each objWindow in objShellWindows
      If Instr(objWindow.LocationURL, strURL) Then
            objWindow.Quit
       End If
Next


objIE.Navigate "http://sms.singtel.com/internetsms/logoutAction.do"


Do While objIE.Busy
 WScript.Sleep 2000
Loop

objIE.Quit
set objIE = nothing
set objIE_Pop = nothing
set objShellWindows = nothing
set objShell = nothing
Attachments:
 
1st screen where we enter destination mobile, sender name & email
 
 
2nd screen where we click "End SMS session" button
 

Answer : Rewrite a VB script ( Visual Basic ) to send SMS message from another Telco SMS website

The code below should solve your problem, i apologies if you got some messages to your phone as the number in the test script was not valid on the network so i used the one from the attached html files.

This will goto the sms send page, enter the details, click send, then click on the end session button after it has sent.
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
strMobile = "988888"
strSender = "Test"
strMessage = "This is a test message"
 
Set objIE = CreateObject("InternetExplorer.Application")
 
objIE.Navigate "http://websms.starhub.com/websmsn/usr/createMsgSessionPageShow.do?method=initCreateSession"
objIE.Visible = True

 
Do While objIE.Busy
      WScript.Sleep 2000
Loop

 
objIE.Document.frmMsgCreateSession.Item("recipients").Value = strMobile
objIE.Document.frmMsgCreateSession.Item("senderName").Value = strSender
objIE.Document.frmMsgCreateSession.Item("message").Value = strMessage
objIE.Document.frmMsgCreateSession.submit

 
Do While objIE.Busy
      WScript.Sleep 2000
Loop

objIE.Document.getElementById("frmMsgSend").getElementsByTagName("INPUT")(6).Click

Do While objIE.Busy
      WScript.Sleep 2000
Loop

objIE.Quit
set objIE = nothing
set objIE_Pop = nothing
set objShellWindows = nothing
set objShell = nothing
Random Solutions  
 
programming4us programming4us