Hi experts,
Im Ron and i have just recently started using VB and have written a small application for sending SMSes.
Code:
Imports System.Net
Imports System.IO
Public Class Form1
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Private Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
'Dim strUrl As String = "xxxxxxxxxxxxxx?user=Username:Password&senderID=xxx&receipientno=xxxx&msgtxt=This is a testxxxx API&state=4"
Dim strUrl As String = "xxxxxxxxxuser=xxx:xxxxx&senderID=xxxxx&receipientno= " & TextBox3.Text & "&msgtxt=" & TextBox4.Text & "&state=" & TextBox5.Text & ""
Dim request As WebRequest = HttpWebRequest.Create(strUrl)
Dim response As HttpWebResponse = DirectCast(request.GetResponse, HttpWebResponse)
Dim s As Stream = DirectCast(response.GetResponseStream(), Stream)
Dim readStream As New StreamReader(s)
Dim dataString As String = readStream.ReadToEnd()
RichTextBox1.Text = dataString.ToString
response.Close()
s.Close()
readStream.Close()
End Sub
Private Sub Button2_click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim mybut As New OpenFileDialog
mybut.Filter = "Text Files (*.txt)|*.txt"
mybut.InitialDirectory = My.Computer.FileSystem.SpecialDirectories.Desktop
If mybut.ShowDialog <> Windows.Forms.DialogResult.OK Then Exit Sub
Dim myfile As String = mybut.FileName
Dim reader As New System.IO.StreamReader(myfile)
TextBox4.Text = reader.ReadToEnd
End Sub
Private Sub TextBox3_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox3.TextChanged
End Sub
Private Sub TextBox4_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox4.TextChanged
End Sub
Private Sub TextBox5_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles TextBox5.TextChanged
End Sub
Private Sub RichTextBox1_TextChanged(ByVal sender As Object, ByVal e As EventArgs) Handles RichTextBox1.TextChanged
End Sub
Private Sub Label4_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Label4.Click
End Sub
Private Sub Label5_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Label5.Click
End Sub
Private Sub Label6_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Label6.Click
End Sub
Private Function strUrl() As String
Throw New NotImplementedException
End Function
End Class
What the code currently does: Button2 Selects a txt file and dumps its contents in the message box.
the Recipient No. needs to be entered manually.
Status needs to be entered as 4.
Now once button 1 is clicked once the rest of the details are furnished, an SMS is sent to the recipient number with the
message box contents as the message.
confirmation of message delievery is sent to the Rich text box.
the SMS sending is already tested and i have been able to manually send messages using the application.
What I require: the process to be automated,
eg once i click a Start Button the program runs and performs the following tasks:
it selects ALL the text files in a particular folder with the text files named as the number to be messaged (eg 99124124124.txt, 923523423.txt etc)
the name of the txt document is fed to the recipient number box which was created while the messages are fed into the message box respectively and the button 1 ie send should be used once the
details are filled in automatically once the valid details are filled in.
these txt files have to be sent on a user defined basis (eg once a day/twice a day the same txt file should be sent to the same number.and this has to be done for that particular text file) (user maybe able to select the numbers using a checkbox etc)
also a STOP button will be needed to ensure that the user can stop the sending of SMS to a particular number (eg stop sending sms to 9212323423) which should not affect the other
numbers.
Is this possible and could some expert guide me with a brief picture of how the code should look like?