mCore™ .NET SMS Library 1.2

mCore.SMS.AutoDeleteNewMessage Property

Description:

The AutoDeleteNewMessage property gets or sets a boolean value that defines whether new messages received will be automatically deleted after raising the NewMessageReceived Event. The AutoDeleteNewMessage property is valid only if NewMessageIndication property is set as True.

Namespace: mCore
Assembly: mCoreLib (in mCoreLib.dll)

Remarks:

Exceptions:

mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
  
   Public Sub New()
      Try     
         SetCommParameters()
         objSMS.NewMessageIndication = True
         objSMS.NewMessageConcatenate = True
         objSMS.AutoDeleteNewMessage = True
      Catch ex As mCore.GeneralException
         MsgBox(ex.Message)
      End Try
   End Sub

   'New Message Event Handling
   'A message box will pop-up whenever
   'a new message is received

   Private Sub objSMS_NewMessageReceived(ByVal sender As Object, _
               ByVal e As mCore.NewMessageReceivedEventArgs) _
               Handles objSMS.NewMessageReceived

      MsgBox("FROM: " & e.Phone & vbCrLf & vbCrLf & _
         "DATE/TIME: " & e.TimeStampRFC & vbCrLf & vbCrLf & _
         "MESSAGE:" & vbCrLf & e.TextMessage, _
         MsgBoxStyle.Information, "NEW MESSAGE RECEIVED")

   End Sub

   Public Sub SetCommParameters()
      Try
         objSMS.Port = "COM1"
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200
         objSMS.DataBits = mCore.DataBits.Eight
         objSMS.StopBits = mCore.StopBits.One
         objSMS.Parity = mCore.Parity.None
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message)
      Catch ex As Exception
      End Try
   End Function
End Class

 
C#

class MyClass
{
   public mCore.SMS objSMS = new mCore.SMS();

   public MyClass()

   {
      try
      {
         SetCommParameters();
         objSMS.NewMessageIndication = true;
         objSMS.NewMessageConcatenate = true;
         objSMS.AutoDeleteNewMessage = true
      }
      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }

      objSMS.NewMessageReceived +=
         new mCore.SMS.NewMessageReceivedHandler(objSMS_NewMessageReceived);
   }

   //New Message Event Handling
   //A message box will pop-up whenever
   //a new message is received

   private void objSMS_NewMessageReceived
      (object sender, mCore.NewMessageReceivedEventArgs e)
   {
      MessageBox.Show("NEW MESSAGE RECEIVED" + "\r\n" +
         "FROM: " + e.Phone + "\r\n" +
         "DATE/TIME: " + e.TimeStampRFC + "\r\n" +
         "MESSAGE:" + "\r\n" + e.TextMessage);
   }

   public static void SetCommParameters()
   {
      try
      {
         objSMS.Port = "COM1";
         objSMS.BaudRate = mCore.BaudRate.BaudRate_19200;
         objSMS.DataBits = mCore.DataBits.Eight;
         objSMS.StopBits = mCore.StopBits.One;
         objSMS.Parity = mCore.Parity.None;
         objSMS.FlowControl = mCore.FlowControl.RTS_CTS;
      }

      catch (mCore.GeneralException e)
      {
         MessageBox.Show(e.ToString());
      }
      catch (Exception e)
      {
      }
   }
}

See Also:

mCore.SMS.NewMessageIndication Property
mCore.SMS.NewMessageConcatenate Property
mCore.SMS.NewMessageReceived Event
mCore.NewMessageReceivedEventArgs Class

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved