#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    Thumbs up VB.NET: Sending automatic SMS from your application


    Friends,

    Please I have developed a VB.net mobile application for sending out automatic sms notifications to all my friends on meeting schedules and other tasks

    iam using windows phone,anyone help how must i make it work in my phone
  2. #2
  3. Humble Learner
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jul 2007
    Location
    Bangalore, India
    Posts
    280
    Rep Power
    120
    How is the meeting scheduled ?
  4. #3
  5. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Sep 2012
    Posts
    2
    Rep Power
    0

    VB.NET: Sending automatic SMS from your application


    Originally Posted by debasisdas
    How is the meeting scheduled ?
    Please find below is the source code:

    Code:
    Option Explicit On
    Option Strict Off
    Imports System
    Imports System.Data
    Imports System.Data.SqlServerCe
    Imports Microsoft.WindowsMobile.PocketOutlook
    Imports System.Resources
    Imports System.IO
    
    Public Class frmMain
        
        Dim formLoadFlag As Boolean = False
        Private Sub MenuExit_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuExit.Click
            Application.Exit() 'Exits the Application
        End Sub
    
        Private Sub showDataInForm()
            txtName.Text = MINUTESDataSet.MINUTES(HScrollBar.Value).Agenda
            DateTimePicker.Value = MINUTESDataSet.MINUTES(HScrollBar.Value).dateOfMeeting
            txtMobileNumber.Text = MINUTESDataSet.MINUTES(HScrollBar.Value).mobileNumber
            txtNotes.Text = MINUTESDataSet.MINUTES(HScrollBar.Value).Minutes
    
            updateRecordCount(MINUTESDataSet.MINUTES(HScrollBar.Value).sno)
        End Sub
    
        Private Sub updateRecordCount(ByVal intCurrentRecord As Integer)
            lblRecCount.Text = "Displaying " & HScrollBar.Value + 1 & " of " _
                & MINUTESDataSet.MINUTES.Rows.Count & " Records"
        End Sub
    
        Private Sub bdTabControl_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles bdTabControl.SelectedIndexChanged
            If formLoadFlag = False Then
                MINUTESTableAdapter.Fill(MINUTESDataSet.MINUTES) 'Filling the data from adapter to dataset
    
                DateTimePicker.MaxDate = Today.AddDays(366)
    
                formLoadFlag = True
            End If
    
            Select Case bdTabControl.SelectedIndex
                Case 0
                    MenuModify.Enabled = True
                    MenuDelete.Enabled = True
    
                    HScrollBar.Maximum = MINUTESDataSet.MINUTES.Rows.Count - 1 'Set the scroll bar value
    
                    If MINUTESDataSet.MINUTES.Rows.Count > 0 Then
                        showDataInForm()
                    Else
                        txtName.Text = ""
                        txtMobileNumber.Text = ""
                        txtNotes.Text = ""
    
                        showMessage("Database is empty. Please fill records.")
                    End If
                Case 1
                    MenuModify.Enabled = False
                    MenuDelete.Enabled = False
    
                    If MINUTESDataSet.MINUTES.Rows.Count < 1 Then
                        showMessage("Database is empty. Please fill records.")
                    End If
                Case 2
                    MenuModify.Enabled = False
                    MenuDelete.Enabled = False
            End Select
        End Sub
    
        Private Sub cmdAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdAdd.Click
            If validateControls() = True Then
                If cmdAdd.Text = "Update" Then
                    addNewData()
    
                    cmdAdd.Visible = False
                    cmdCancel.Visible = False
                    ToggleTextBoxReadOnly(True) 'Make the textboxes read only
                ElseIf cmdAdd.Text = "Modify" Then
                    updateRecord(MINUTESDataSet.MINUTES(HScrollBar.Value).sno)
    
                    cmdAdd.Visible = False
                    cmdCancel.Visible = False
                    ToggleTextBoxReadOnly(True) 'Make the textboxes read only
                End If
            End If
        End Sub
    
        Private Function validateControls() As Boolean
            If txtName.Text <> "" And txtMobileNumber.Text <> "" And txtMobileNumber.TextLength > 9 And txtMobileNumber.TextLength < 14 Then
                validateControls = True
                Exit Function
            End If
    
            showMessage("Please enter information in mandatory fields.")
            validateControls = False
        End Function
    
        Private Sub ToggleTextBoxReadOnly(ByVal flag As Boolean)
            tabDetView.BringToFront() 'Gives focus to Detail View screen but does not activate it
    
            txtName.ReadOnly = flag
            txtName.Text = ""
    
            DateTimePicker.Enabled = IIf(flag = True, False, True)
            cmdAdd.Visible = IIf(flag = True, False, True) 'Add Record button is enabled
            cmdCancel.Visible = IIf(flag = True, False, True)
    
            txtMobileNumber.ReadOnly = flag
            txtMobileNumber.Text = ""
    
            txtNotes.ReadOnly = flag
            txtNotes.Text = ""
    
            MenuItem.Enabled = flag
            HScrollBar.Enabled = flag 'Scroll bar is also toggled to avoid data loss
    
            'Fires the initialization of Detail View
            If flag = True Then bdTabControl.SelectedIndex = 0
        End Sub
    
        Private Sub MenuAdd_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuAdd.Click
            ToggleTextBoxReadOnly(False) 'Enable textboxes for data entry
            txtName.Focus() 'Gives focus to First text box (txtname)
            cmdAdd.Text = "Update"
            DateTimePicker.Value = Now().ToShortDateString()
        End Sub
    
        Private Sub cmdCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdCancel.Click
            cmdAdd.Visible = False
            cmdCancel.Visible = False
            ToggleTextBoxReadOnly(True) 'Make the textboxes read only
        End Sub
    
        Private Sub showMessage(ByVal strMsg As String)
            MsgBox(strMsg, MsgBoxStyle.Information, Me.Text)
        End Sub
    
        Private Sub txtMobileNumber_KeyPress(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyPressEventArgs) Handles txtMobileNumber.KeyPress
            'Convert.ToInt16(e.KeyChar) <> 8 is for ignoring backspace key
            If txtMobileNumber.ReadOnly = False And IsNumeric(e.KeyChar) = False And Convert.ToInt16(e.KeyChar) <> 8 Then
                txtMobileNumber.Text = ""
                showMessage("Please enter numbers only for mobile number.")
            End If
        End Sub
    
        Private Sub addNewData(Optional ByVal sno As Integer = 0)
            MINUTESTableAdapter.Insert(txtName.Text, DateTimePicker.Value, _
                                            txtMobileNumber.Text, txtNotes.Text)
    
            MINUTESTableAdapter.Fill(MINUTESDataSet.MINUTES) 'Refill the table with new row
    
            If sno = 0 Then showMessage("Entry added successfully.")
            HScrollBar.Value = 0
        End Sub
    
        Private Sub HScrollBar_ValueChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles HScrollBar.ValueChanged
            showDataInForm()
        End Sub
    
        Private Sub MenuModify_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuModify.Click
            ToggleTextBoxReadOnly(False) 'Enable textboxes for data entry
            showDataInForm()
            txtName.Focus() 'Gives focus to First text box (txtname)
            cmdAdd.Text = "Modify"
        End Sub
    
        Private Sub MenuDelete_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuDelete.Click
            Dim ans As Integer = MsgBox("Are you sure you wish to delete the current record?", MsgBoxStyle.YesNo, Me.Text)
    
            If ans = 6 Then
                MINUTESTableAdapter.Delete(MINUTESDataSet.MINUTES(HScrollBar.Value).sno)
    
                MINUTESTableAdapter.Fill(MINUTESDataSet.MINUTES)
                bdTabControl.SelectedIndex = 0
            End If
        End Sub
    
        Private Sub MenuCheckBD_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuCheckMn.Click
            checkminutes()
        End Sub
    
        Private Sub cmdStop_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdStop.Click
            Timer.Interval = 0
            Timer.Enabled = False
            cmdStop.Visible = False
        End Sub
    
        Private Sub Timer_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer.Tick
            Application.Exit()
        End Sub
    
        Private Sub frmMain_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyBase.Load
            Dim st As New StreamReader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\txtMsg.txt")
    
            txtMessage.Text = st.ReadToEnd()
            checkminutes()
    
            st.Close()
        End Sub
    
        Private Sub checkminutes()
            Dim i As Integer = 0
    
            Try
                For i = 0 To MINUTESDataSet.MINUTES.Rows.Count - 1
                    If MINUTESDataSet.MINUTES(i).dateOfMeeting.Day = Date.Now.Day And MINUTESDataSet.MINUTES(i).dateOfMeeting.Date.Month = Date.Now.Month Then
                        Dim sms As New SmsMessage(MINUTESDataSet.MINUTES(i).mobileNumber, _
                                            "Hi " & MINUTESDataSet.MINUTES(i).Agenda & vbCrLf & txtMessage.Text)
                        sms.Send()
    
                        Dim sms2 As New SmsMessage("+999999999999", _
                                            "Hi " & MINUTESDataSet.MINUTES(i).Agenda & vbCrLf & txtMessage.Text)
                        sms2.Send()
                    End If
                Next
            Catch ex As Exception
                showMessage("The database is empty. Fill some entries year.")
            End Try
        End Sub
    
        Private Sub updateRecord(ByVal sno As Integer)
            'Delete that entry
            MINUTESTableAdapter.Delete(MINUTESDataSet.MINUTES(HScrollBar.Value).sno)
            MINUTESTableAdapter.Fill(MINUTESDataSet.MINUTES)
    
            'Add new row for that (Direct Update not supported)
            addNewData(sno)
    
            MINUTESTableAdapter.Fill(MINUTESDataSet.MINUTES)
            showMessage("Entry modified successfully.")
            HScrollBar.Value = 0
        End Sub
    
        Private Function getResult4mQuery(ByVal strQuery As String) As Integer
            Dim cn As New Data.SqlServerCe.SqlCeConnection("Data Source=" & System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\MINUTES.sdf; Password=alwahco")
            Dim cmd As New Data.SqlServerCe.SqlCeCommand(strQuery, cn)
            Dim dr As Data.SqlServerCe.SqlCeDataReader
    
            cn.Open()
            cmd.CommandType = Data.CommandType.Text
            dr = cmd.ExecuteReader()
            dr.Read()
            getResult4mQuery = dr(0)
    
            cn.Close()
        End Function
    
        Private Sub cmdEditMsg_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles cmdEditMsg.Click
            If cmdEditMsg.Text = "Edit Message" Then
                cmdEditMsg.Text = "Save Message"
                txtMessage.ReadOnly = False
            Else
                Try
                    Dim sw As New StreamWriter(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase) & "\txtMsg.txt")
    
                    sw.Write(txtMessage.Text)
    
                    sw.Close()
    
                    cmdEditMsg.Text = "Edit Message"
                    txtMessage.ReadOnly = True
                Catch ex As Exception
                    MsgBox(ex.Message)
                End Try
            End If
        End Sub
    
        Private Sub DataGrid_CurrentCellChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles DataGrid.CurrentCellChanged
    
        End Sub
    
        Private Sub lblDetails_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblDetails.ParentChanged
    
        End Sub
    
        Private Sub lblTitle_ParentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles lblTitle.ParentChanged
    
        End Sub
    
        Private Sub BDayBindingSource_CurrentChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mINUTESBindingSource.CurrentChanged
    
        End Sub
    
        Private Sub MenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MenuItem.Click
    
        End Sub
    
        Private Sub frmMain_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles MyBase.KeyDown
            If (e.KeyCode = System.Windows.Forms.Keys.Up) Then
                'Up
            End If
            If (e.KeyCode = System.Windows.Forms.Keys.Down) Then
                'Down
            End If
            If (e.KeyCode = System.Windows.Forms.Keys.Left) Then
                'Left
            End If
            If (e.KeyCode = System.Windows.Forms.Keys.Right) Then
                'Right
            End If
            If (e.KeyCode = System.Windows.Forms.Keys.Enter) Then
                'Enter
            End If
    
        End Sub
    
    End Class
    Last edited by medialint; September 4th, 2012 at 01:46 PM. Reason: added CODE tags ... please use in future

IMN logo majestic logo threadwatch logo seochat tools logo