mCore™ .NET SMS Library 1.2

mCore.SMS.SendDelay Property

Description:

The SendDelay property gets or sets a Long Integer value to define the minimum time delay interval between two consecutive messages in milliseconds.

When sending a batch of outgoing messages, immediately one after another, during a network busy period, it may result in delivery failure and retries. Increase the value of SendDelay property to avoid such errors.


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

Exceptions:

mCore.GeneralException

Usage Example:

Visual Basic

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

      Dim strMsg As String, strPhone(5) As String
      Dim i As Integer, blnAllMsgSent As Boolean = True
      strMsg = "This is a test message"
      strPhone(0) = "+919873094767"
      strPhone(1) = "+919818247005"
      strPhone(2) = "9810054632"
      strPhone(3) = "+919810361553"
      strPhone(4) = "+919832076345"
      strPhone(5) = "9840043784"
      Try
         SetCommParameters()
         objSMS.Encoding = mCore.Encoding.GSM_Default_7Bit
         objSMS.LongMessage = mCore.LongMessage.Concatenate
         objSMS.SendDelay = 1000
         objSMS.SendRetry = 2

         For i = 0 to 5
            Try
               objSMS.SendSMS(strPhone(i), strMsg)

            Catch ex As mCore.SMSSendException
               blnAllMsgSent = False
            End Try
         Next
         If blnAllMsgSent Then
            MsgBox("All messages sent!")
         Else
            MsgBox("At least one message sending failed!")
         End If

      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; string[] strPhone;
      strPhone = new string[5]; Boolean blnAllMsgSent = true;

      strMsg = "This is a test message";
      strPhone[0] = "+919873094767";
      strPhone[1] = "+919818247005";
      strPhone[2] = "9810054632";
      strPhone[3] = "+919810361553";
      strPhone[4] = "+919832076345";
      try
      {
         SetCommParameters();
         objSMS.Encoding = mCore.Encoding.GSM_Default_7Bit;
         objSMS.LongMessage = mCore.LongMessage.Concatenate;
         objSMS.SendDelay = 1000;
         objSMS.SendRetry = 2;
         for (int i = 0; i < 5; i++)
         {
            try
            {
               objSMS.SendSMS(strPhone[i], strMsg);
            }
            catch (mCore.SMSSendException ex)
            {
               blnAllMsgSent = false;
            }
         }
         if (blnAllMsgSent)
         {
            MessageBox.Show("All messages sent!");
         }
         else
         {
            MessageBox.Show("At least one message sending failed!");
         }
      }
      catch(mCore.GeneralException ex)
      {
         MessageBox.Show(ex.ToString());
      }
   }

   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.SendRetry Property
mCore.SMS.SendSMS Method

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved