I got this code from their PDF file.
I was wondering if we can use .net code in excel and assign it to a button?
Calling HTTP API Using .Net
Imports System.IO
Imports System.Net
Imports System.Data
Inherits System.Web.UI.Page
Protected Sub Page_Load(ByVal sender As Object, ByVal e As
System.EventArgs) Handles Me.Load
Dim WebRequest As Net.WebRequest 'object for WebRequest
Dim WebResonse As Net.WebResponse 'object for WebResponse
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
' DEFINE PARAMETERS USED IN URL
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''' ''''''''
'Username that is to be used for submission
'i.e. Dim UserName As String = "tester"
Dim UserName As String = ""
' password that is to be used along with username
'i.e. Dim Password As String = "password"
Dim Password As String = ""
'Message content that is to be transmitted
Dim Message As String = "Test SMS"
'Url Encode message
Message = HttpUtility.UrlEncode(Message)
'Sender Id to be used for submitting the message
'i.e. Dim SenderName As String = "test"
Dim SenderId As String = "Tester"
'Destinations to which message is to be sent For submitting more
than one
'destination at once destinations should be comma separated Like
'91999000123,91999000124
Dim Destination As String = ""
'''''''CODE COMPLETE TO DEFINE PARAMETER''''''''''''''''
Dim WebResponseString As String = ""
Dim URL As String = "http://
Smsidea.co.in/sendsms.aspx?mobile=" & UserName & "&pass=" & Password & "&senderid="
&SenderId & "
&to=" & Destination & "&msg=" & Message & ""
WebRequest = Net.HttpWebRequest.Create(URL) 'Hit URL Link
WebRequest.Timeout = 25000
WebResonse = WebRequest.GetResponse 'Get Response
Dim reader As IO.StreamReader = New
IO.StreamReader(WebResonse.GetResponseStream)
'Read Response and store in variable
WebResponseString = reader.ReadToEnd()
WebResonse.Close()
Response.Write(WebResponseString) 'Display Response.
Catch ex As Exception
WebResponseString = "Request Timeout" 'If any exception
occur.
Response.Write(WebResponseString)
End Try
End Sub
End Class
Bookmarks