[GH-ISSUE #481] Excel VBA #59

Closed
opened 2026-03-03 16:36:19 +03:00 by kerem · 1 comment
Owner

Originally created by @DLInvestPro on GitHub (Jul 10, 2024).
Original GitHub issue: https://github.com/NdoleStudio/httpsms/issues/481

I have a spreadsheet with formulas that I am using for my students. I am currently testing the following vba and not seeing success. I think I have everything correct nad yes, I have my api ket in the code. What ma I missing?
Sub SendBulkSMS()
Dim lastRow As Long
Dim i As Long
Dim phoneNumber As String
Dim message As String
Dim apiKey As String
Dim url As String
Dim xmlhttp As Object

' Your httpSMS API key
apiKey = "your_httpsms_api_key"

' Find the last row with data in column A
lastRow = Cells(Rows.Count, 1).End(xlUp).Row

' Loop through each row
For i = 2 To lastRow
    phoneNumber = Cells(i, 1).Value
    message = Cells(i, 2).Value
    
    ' Construct the URL for the API request
    url = "https://httpsms.com/api/send?apiKey=" & apiKey & "&to=" & phoneNumber & "&message=" & message
    
    ' Create the XMLHTTP object
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    
    ' Open the request
    xmlhttp.Open "GET", url, False
    
    ' Send the request
    xmlhttp.send
    
    ' Check the response status
    If xmlhttp.Status = 200 Then
        Cells(i, 3).Value = "Sent"
    Else
        Cells(i, 3).Value = "Failed: " & xmlhttp.Status & " - " & xmlhttp.StatusText
    End If
Next i

End Sub

Originally created by @DLInvestPro on GitHub (Jul 10, 2024). Original GitHub issue: https://github.com/NdoleStudio/httpsms/issues/481 I have a spreadsheet with formulas that I am using for my students. I am currently testing the following vba and not seeing success. I think I have everything correct nad yes, I have my api ket in the code. What ma I missing? Sub SendBulkSMS() Dim lastRow As Long Dim i As Long Dim phoneNumber As String Dim message As String Dim apiKey As String Dim url As String Dim xmlhttp As Object ' Your httpSMS API key apiKey = "your_httpsms_api_key" ' Find the last row with data in column A lastRow = Cells(Rows.Count, 1).End(xlUp).Row ' Loop through each row For i = 2 To lastRow phoneNumber = Cells(i, 1).Value message = Cells(i, 2).Value ' Construct the URL for the API request url = "https://httpsms.com/api/send?apiKey=" & apiKey & "&to=" & phoneNumber & "&message=" & message ' Create the XMLHTTP object Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0") ' Open the request xmlhttp.Open "GET", url, False ' Send the request xmlhttp.send ' Check the response status If xmlhttp.Status = 200 Then Cells(i, 3).Value = "Sent" Else Cells(i, 3).Value = "Failed: " & xmlhttp.Status & " - " & xmlhttp.StatusText End If Next i End Sub
kerem closed this issue 2026-03-03 16:36:20 +03:00
Author
Owner

@AchoArnold commented on GitHub (Jul 10, 2024):

Hello @DLInvestPro
It has to be a POST request and not GET. unfortunately I don't know VBA. I think you'll have better luck asking chatGPT to create a VBA script for you

<!-- gh-comment-id:2221597562 --> @AchoArnold commented on GitHub (Jul 10, 2024): Hello @DLInvestPro It has to be a `POST` request and not `GET`. unfortunately I don't know VBA. I think you'll have better luck asking chatGPT to create a VBA script for you
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/httpsms#59
No description provided.