mCore™ .NET SMS Library 1.2

mCore.SMS.SendRetry Property

Description:

The SendRetry property gets or sets a Integer value to define the maximum number of retries after there is a failure in first attempt to send a SMS. If SendRetry is set 0, it means there will be no retry attempts.

There are times when the message actually is transmitted but due to network congestion or low signal strength, the SMSC may not respond properly and therefore mCore will consider it as error and retry sending (if SendRetry is set to a value of 1 or more).


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

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved