mCore™ .NET SMS Library 1.2

mCore.SMS.SendSmartMessage Method

Description:

The SendSmartMessage method sends a Smart SMS i.e it sends a text message to a specified application port of a mobile phone device.

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

Overload List:

Name Description
SendSmartMessage (ByVal DestinationNumber As String, ByVal TextMessage As String, ByVal DestinationPort As Integer) Sends a specified text message (TextMessage) to a specified application port (DestinationPort) of a mobile phone number (DestinationNumber).
SendSMS (ByVal DestinationNumber As String, ByVal TextMessage As String, ByVal DestinationPort As Integer, ByVal SourcePort As Integer) Sends a specified text message (TextMessage) to a specified phone number (DestinationNumber) and specified source port (SourcePort) of a mobile phone number (DestinationNumber).

Remarks:

Exceptions:

mCore.SMSSendException
mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
   Public Sub SendMessage()

      Dim strMsg As String
      strMsg = "This is a sample smart message text."
      Try
         SetCommParameters()
         Try

            'Send Smart SMS to phone application port 1725
            objSMS.SendSmartMessage("+919873094767", strMsg, 1725)
            MsgBox("Smart SMS Sent!")
         Catch ex As mCore.SMSSendException
            MsgBox("Smart SMS Failed!" & vbCrLf & ex.Message)
         End Try

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message, MsgBoxStyle.Critical, "mCore Demo")
      Catch ex As Exception
      End Try
   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 static void SendMessage()
   {
      string strMsg = "This is a sample smart message text.";
      try
      {

         SetCommParameters();
         try
         {

            //Send Smart SMS to phone application port 1725
            objSMS.SendSMS("+919873094767", strMsg, 1725);
            MessageBox.Show("Smart SMS Sent!");
         }
         catch (mCore.SMSSendException e)
         {
            MessageBox.Show("Message Failed!" + "\r\n" + e.ToString());
         }
      }

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

   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.SMSSendException Class

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved