kelly mort
Well-known Member
- Joined
- Apr 10, 2017
- Messages
- 2,169
- Office Version
- 2016
- Platform
- Windows
Code:
Sub SendSMS()
Dim URL As String
Dim ApiKey As String
Dim httpRequest As Object
Dim responseText As String
Dim values As String
URL = "https://sms.arkesel.com/api/v2/sms/send"
ApiKey = "RlBrQ21ISXlhTnJuZXNmQnJFZVhEcmxFa0U"
Set httpRequest = CreateObject("MSXML2.XMLHTTP")
httpRequest.Open "POST", URL, False
' Set request headers
httpRequest.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"
httpRequest.setRequestHeader "api-key", ApiKey
' Set request body
values = "sender=Thank You&message=Hello World from VB6&recipients[]=XXXXXXXXXX"
httpRequest.send values
' Get response text
responseText = httpRequest.responseText
' Print response text to immediate window
Debug.Print responseText
End Sub
Hi everyone,
I have this code here for sending sms.
I used chatGpt to covert it from VB to VBA as seen above.
The thing is that on this line:
Code:
values = "sender=Thank You&message=Hello World from VB6&recipients[]=XXXXXXXXXX"
I want to store the message in a variable and call it later. Something like this:
Code:
text1 = “Hello world “
text2 = “Help me out”
myVar = text1 & text2
values = "sender=Thank You&message=myVar&recipients[]=XXXXXXXXXX"
But can’t do that because the syntax is not a familiar one for me.
Can someone help me fix it?
Thanks in advance