I am attempting to use T-Mobile's web site to send SMS messages. (I
couldn't find a free web service for this purpose...if you know of a
free one compatible with T-mobile let me know.) Using examples from
multiple sources, I have come up with the following function (VB.net
1.1):
Private Function SendTMobileSMS( ByVal strPhoneNumber As String,
ByVal strMessage As String, ByVal strFrom As String)
Dim strURL As String =
"https://wmg.tmomail.net/customer_site/jsp/messaging_lo.js p"
Dim strPostData As String
strPostData = "min=" & HttpUtility.Url Encode(strPhone Number)
'To
strPostData += "&require_sende r=" &
HttpUtility.Url Encode(strFrom) ' From
strPostData += "&text=" & HttpUtility.Url Encode(strMessa ge) '
Phone Number
strPostData += "&msgTermsU se=" & HttpUtility.Url Encode("Y")
'Agree to terms
Dim myPostEncoding As Byte() =
System.Text.Enc oding.GetEncodi ng(1252).GetByt es(strPostData)
Dim myRequest As HttpWebRequest =
CType(WebReques t.Create(strURL ), HttpWebRequest)
myRequest.Metho d = "POST"
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
myRequest.Conte ntLength = myPostEncoding. Length
myRequest.Cooki eContainer = New CookieContainer
Dim myStream As IO.Stream = myRequest.GetRe questStream
myStream.Write( myPostEncoding, 0, myPostEncoding. Length)
myStream.Flush( )
myStream.Close( )
End Function
The request results in a response indicating an error has occured. The
page is fairly simple...3 text boxes, a check box, and a send message
button. I did notice potentially two difficulties however...the web
page has 3 forms, and the send message buttun is not actually a submit
button but an image button. I'm not sure what I am doing wrong here.
This in advance for your help.
couldn't find a free web service for this purpose...if you know of a
free one compatible with T-mobile let me know.) Using examples from
multiple sources, I have come up with the following function (VB.net
1.1):
Private Function SendTMobileSMS( ByVal strPhoneNumber As String,
ByVal strMessage As String, ByVal strFrom As String)
Dim strURL As String =
"https://wmg.tmomail.net/customer_site/jsp/messaging_lo.js p"
Dim strPostData As String
strPostData = "min=" & HttpUtility.Url Encode(strPhone Number)
'To
strPostData += "&require_sende r=" &
HttpUtility.Url Encode(strFrom) ' From
strPostData += "&text=" & HttpUtility.Url Encode(strMessa ge) '
Phone Number
strPostData += "&msgTermsU se=" & HttpUtility.Url Encode("Y")
'Agree to terms
Dim myPostEncoding As Byte() =
System.Text.Enc oding.GetEncodi ng(1252).GetByt es(strPostData)
Dim myRequest As HttpWebRequest =
CType(WebReques t.Create(strURL ), HttpWebRequest)
myRequest.Metho d = "POST"
myRequest.Conte ntType = "applicatio n/x-www-form-urlencoded"
myRequest.Conte ntLength = myPostEncoding. Length
myRequest.Cooki eContainer = New CookieContainer
Dim myStream As IO.Stream = myRequest.GetRe questStream
myStream.Write( myPostEncoding, 0, myPostEncoding. Length)
myStream.Flush( )
myStream.Close( )
End Function
The request results in a response indicating an error has occured. The
page is fairly simple...3 text boxes, a check box, and a send message
button. I did notice potentially two difficulties however...the web
page has 3 forms, and the send message buttun is not actually a submit
button but an image button. I'm not sure what I am doing wrong here.
This in advance for your help.