mCore™ .NET SMS Library 1.2

mCore.NewMessageReceivedEventArgs Class

Description:

The NewMessageReceivedEventArgs class prepares data for the NewMessageReceived event.

Namespace: mCore
Assembly: mCoreLib (in mCoreLib.dll)
Inherits: System.EventArgs

Exceptions:

mCore.GeneralException

Properties:

Property Description Type
Phone SMS sender phone number String
ReferenceNumber Concatenated SMS reference number (valid if mCore.SMS.NewMessageConcatenate property is set as False, and will be same for all parts of same concatenated SMS) Integer
SequenceNumber Concatenated SMS sequence number (valid if mCore.SMS.NewMessageConcatenate property is set to False, and will range from 1 to TotalParts property Integer
SMSC Sender SMSC address String
TextMessage SMS text message String
TimeStamp SMS sending date and time DateTime
TimeStampRFC SMS sending date and time as RFC-822 format string String
TimeZone Time zone of SMS sender as difference in minutes between TimeStamp value and UTC Integer
TotalParts Total messages if this message is a part of a concatenated SMS (valid if mCore.SMS.NewMessageConcatenate property is set to False) Integer

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.NewMessageReceivedEventHandler(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.NewMessageReceived Event
mCore.SMS.NewMessageReceivedEventHandler Delegate

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved