Has anyone got code for SMS Messages?

DCrake

Remembered
Local time
Today, 20:14
Joined
Jun 8, 2005
Messages
8,620
Hi All

Been asked to build a module to enable the user to send SMS text messages to mobile phones. I know Access can do this and some sample code I have seen was in VB and it uses MSXML2 but if anyone has any different approaches I would be interested.

Cheers
CodeMaster::cool:
 
I didn't know this was possible. Can you post a few words or links about how this works?

I made a project a few days ago, where I had to parse XML files, if you need some help with parsing XML, just ask.
 
Simple Software Solutions

Thanks for your enquiry.
This is the contents of the sms.bas module

Public Function SendMessage(username As String, password As String, _
destination As String, message As String)


Dim xmlstring As String

xmlstring = "<?xml version=" & Chr(34) & "1.0" & Chr(34) & "?> " & _
"<Request xmlns:xsi=" & Chr(34) & "http://www.w3.org/2001/XMLSchema-instance" & Chr(34) & " xsi:noNamespaceSchemaLocation=" & Chr(34) & "http://schema.2sms.com/1.0/0410_RequestSendMessage.xsd" & Chr(34) & " Version = " & Chr(34) & "1.0" & Chr(34) & ">" & _
"<Identification>" & _
"<UserID><![CDATA[" & username & "]]></UserID>" & _
"<Password>" & password & "</Password>" & _
"</Identification>" & _
"<Service>" & _
"<ServiceName>SendMessage</ServiceName>" & _
"<ServiceDetail>" & _
"<SingleMessage>" & _
"<Destination>" & destination & "</Destination>" & _
"<Text><![CDATA[" & message & "]]></Text>" & _
"</SingleMessage>" & _
"</ServiceDetail>" & _
"</Service>" & _
"</Request>"

'open connection to server and send

Dim xmlrequest As MSXML2.XMLHTTP
Set xmlrequest = New MSXML2.XMLHTTP

xmlrequest.Open "POST", "http://www.2sms.com/xml/xml.jsp", False

xmlrequest.setRequestHeader "content-type", "text/xml"
xmlrequest.send xmlstring

'get the response back

response = xmlrequest.responseText

'set up DOM to parse
Dim xmlresponse As MSXML2.DOMDocument30
Set xmlresponse = New MSXML2.DOMDocument

xmlresponse.async = False
xmlresponse.resolveExternals = False
xmlresponse.validateOnParse = False


On Error Resume Next


xmlresponse.loadXML response

'pull out relevant variables from response

javaresult = (xmlresponse.getElementsByTagName("Result").Item(0).Text)
errorCode = (xmlresponse.getElementsByTagName("ErrorCode").Item(0).Text)
errorreason = (xmlresponse.getElementsByTagName("ErrorReason").Item(0).Text)
messageid = (xmlresponse.getElementsByTagName("MessageID").Item(0).Text)


If errorCode = "00" Then


SendMessage = javaresult
Else
If errorreason = "" Then
SendMessage = "Message Failed - Unknown Error"
Else
SendMessage = "Message FAILED. (Reason: " & errorreason & ")"
End If
End If

End Function

see the pic to view the form

on the click of the button was this code

Private Sub btnSend_Click()
btnSend.Enabled = False
MsgBox (SendMessage(txtusername.Text, txtpassword.Text, txtNumber.Text, txtMessage.Text))
btnSend.Enabled = True
End Sub

When I tried it I got the message that the Message Failed.
 

Attachments

  • untitled.JPG
    untitled.JPG
    14.9 KB · Views: 164

Users who are viewing this thread

Back
Top Bottom