mCore™ .NET SMS Library 1.2

mCore.SMS.DeliveryReport Property

Description:

The DeliveryReport property gets or sets a boolean value that defines whether a delivery status report is requested for SMS sent using SMS.SendSMS, WapPush.Send, vCalendar.Send, vCalendar.SendFile, vCard.Send and vCard.SendFile methods. When set as True, delivery report is requested and when set to False, delivery report is not requested.

For SMS.SendSMS method, if LongMessage property is set as mCore.SMS.EnumLongMessage.Concatenate then delivery report request will be sent only for the last of all the part messages.

For WapPush.Send, vCalendar.Send, vCalendar.SendFile, vCard.Send and vCard.SendFile methods, if the message is longer than one message then delivery report request will be sent only for the last of all the part messages.


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 SendMessage()
      Dim strResult As String = ""
      Dim strMsg As String = "This is a test message"
      Try
         SetCommParameters()
         objSMS.Encoding = mCore.Encoding.GSM_Default_7Bit
         objSMS.LongMessage = mCore.LongMessage.Concatenate
         objSMS.DeliveryReport = True
         Try
            strResult = objSMS.SendSMS("+919873094767", strMsg)

            'Note the message reference number returned
            'This reference number will also be returned
            'in the delivery report

            MsgBox(strResult)
         Catch ex As mCore.SMSSendException
            MsgBox("Message 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

   'Delivery Report Event Handling
   'A message box will pop-up whenever
   'a delivery report is received

   Private Sub objSMS_NewDeliveryReport(ByVal sender As Object, _
               ByVal e As mCore.DeliveryReportEventArgs) _
               Handles objSMS.NewDeliveryReport
      If e.Status Then
         MsgBox("MESSAGE DELIVERED" & vbCrLf & vbCrLf & "TO: " & _
               e.Phone & vbCrLf & vbCrLf & "DELIVERY DATE/TIME: " _
               & e.DeliveryTimeStamp.ToString & vbCrLf & vbCrLf & _
               "[Message Ref.: " & e.MessageReference.ToString & _
               "]", MsgBoxStyle.Information, "DELIVERY REPORT")
      Else
         MsgBox("MESSAGE DELIVERY FAILED" & vbCrLf & vbCrLf & _
               "TO: " & e.Phone & vbCrLf & vbCrLf & _
               "REPORT DATE/TIME: " & e.DeliveryTimeStamp & _
               vbCrLf & vbCrLf & "[Message Ref.: " & _
               e.MessageReference.ToString & "]", _
               MsgBoxStyle.Critical, "DELIVERY REPORT")
      End If
   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()

   {
      objSMS.NewDeliveryReport +=
         new mCore.SMS.DeliveryReportHandler(objSMS_NewDeliveryReport);
   }

   public static void SendMessage()
   {
      string strResult = "";
      string strMsg = "This is a test message"
      try
      {

         SetCommParameters();
         objSMS.Encoding = mCore.Encoding.GSM_Default_7Bit;
         objSMS.LongMessage = mCore.LongMessage.Concatenate;
         objSMS.DeliveryReport = true;
            try
            {
               strResult = objSMS.SendSMS("+919873094767", strMsg);

               //Note the message reference number returned
               //This reference number will also be returned
               //in the delivery report

               MessageBox.Show(strResult);
            }
            catch (mCore.SMSSendException e)
            {
               MessageBox.Show("Message Failed!" + "\r\n" + e.ToString());
            }
      }

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

   //Delivery Report Event Handling
   //A message box will pop-up whenever
   //a delivery report is received

   private void objSMS_NewDeliveryReport
      (object sender, mCore.DeliveryReportEventArgs e)
   {
      if (e.Status)
      {
         MessageBox.Show("MESSAGE DELIVERED" + "\r\n\r\n" +
            "TO: " + e.Phone + "\r\n\r\n" +
            "DELIVERY DATE/TIME: " + e.DeliveryTimeStamp.ToString() +
            "\r\n\r\n" + "[Message Ref.: " +
            e.MessageReference.ToString() + "]");
      }
      else
      {
         MessageBox.Show("MESSAGE DELIVERY FAILED" + "\r\n\r\n" +
            "TO: " + e.Phone + "\r\n\r\n" +
            "REPORT DATE/TIME: " + e.DeliveryTimeStamp.ToString() +
            "\r\n\r\n" + "[Message Ref.: " +
            e.MessageReference.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.NewDeliveryReport Event
mCore.NewDeliveryReportEventArgs Class

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved