-
-
Notifications
You must be signed in to change notification settings - Fork 270
Closed
Description
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
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels