Code for POST VBA

WebSMS and 'Email to SMS' services
Post Reply
Posts: 8
Joined: Fri Aug 06, 2010 12:52 pm
Location: Margaret River

Code for POST VBA

Post by frimbia » Fri Aug 06, 2010 2:22 pm

As i cant find any example code on this site, I thought I would put some up for comment.
This code sends a Exetel SMS message - it needs to be very slightly adapted to send bulk messages etc etc.
It uses late biding so no need to reference anything.

This is VBA and can be used in Access, Excel etc.

Code: Select all

Public Function ExetelSMS(strnumber As String, strBody As String, strUserName As String, _
                            strPassword As String, strSender As String)
Dim myURL As String
Dim response As String
Dim httpObj As Object

    Set httpObj = CreateObject("Microsoft.xmlhttp")
    myURL = "" & strUserName _
        & "&password=" & strPassword & "&mobilenumber=" & strnumber & "&message=" _
        & strBody & "&sender=" & strSender & "&messagetype=Text"

    httpObj.Open "POST", myURL, False
    httpObj.send (myURL)
    response = httpObj.responseText
    MsgBox response
End Function

Volunteer Site Admin
Posts: 6003
Joined: Mon Nov 13, 2006 1:16 pm
Location: Sydney

Re: Code for POST VBA

Post by Dazzled » Fri Aug 06, 2010 3:47 pm

Thanks frimbia. Now that many BSD/Linux shell tools are being ported to Windows, you might also be interested in a one-(long)liner using curl to send data by the POST method. See This is a standalone executable command rather than being integrated into Excel etc, but it lends itself to browser and desktop buttons. Like the subroutine, you would need an input for the message details. Curl has such a bewildering array of uses I'd google for a POST tutorial.

Post Reply