mCore™ .NET SMS Library 1.2

vCalendar.SendFileToQueue Method

Description:

The SendFileToQueue method reads the specified vCalendar file (.vcs file) from the specified path on the disk and submits it to the message queue (instance of mCore.Queue class returned by mCore.SMS.Queue method) for sending as SMS to a mobile phone device defined by the destination number specified in the Destination property at the time of submitting to the queue.
 

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

Overload List:

Name Description
SendFileToQueue (vCalendarFile As String) Sends the contents of the vCalendar file (vCalendarFile) to the message queue with message queue priority set as Normal.
SendFileToQueue (vCalendarFile As String, Priority As SMS.EnumQueuePriority) Sends the contents of the vCalendar file (vCalendarFile) to the message queue with message queue priority set as defined by 'Priority'.

Remarks:

Exceptions:

mCore.vCalendarException
mCore.GeneralException

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
   Public Sub SendQueue()
      Dim objVCAL As mCore.vCalendar = objSMS.vCalendar
      Dim strVCSFile As String = "c:\meeting.vcs"
      Dim strKey As String = ""
      Try
         SetCommParameters()

         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.High)
         MsgBox("vCalendar message added to queue." & vbCrLf & _
                  "[Queue Key: " & strKey & "]")

         objVCAL.Destination = "+919810098765"
         'Following message is sent with normal queue priority
         strKey = objVCAL.SendFileToQueue(strVCSFile)
         MsgBox("vCalendar message added to queue." & vbCrLf & _
                  "[Queue Key: " & strKey & "]")

         objVCAL.Destination = "+919811045678"
         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.Low)
         MsgBox("vCalendar message added to queue." & vbCrLf & _
                  "[Queue Key: " & strKey & "]")

         'Message queue is enabled
         objSMS.Queue.Enabled = True

         'Messages can be added to the queue even
         'when the Message queue is enabled

         objVCAL.Destination = "+919873012345"
         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.High)
         MsgBox("vCalendar message added to queue." & vbCrLf & _
                  "[Queue Key: " & strKey & "]")

      Catch ex As mCore.GeneralException
         MsgBox(ex.Message, MsgBoxStyle.Critical, "mCore Demo")
      Catch ex As Exception
      End Try
   End Sub

   'Event at the start of sending a queued vCalendar message
   Private Sub objSMS_QueueVCalendarSending(ByVal sender As Object, _
               ByVal e As mCore.QueueVCalendarSendingEventArgs) _
               Handles objSMS.QueueVCalendarSending
      MsgBox("Sending vCalendar message to: " & e.DestinationNumber & vbCrLf & _
            "[Queue Key: " & e.QueueMessageKey & _
            "]", MsgBoxStyle.Information, "SENDING VCALENDAR")
   End Sub

   'Event at the end of sending a queued vCalendar message

   Private Sub objSMS_QueueVCalendarSent(ByVal sender As Object, _
               ByVal e As mCore.QueueVCalendarSentEventArgs) _
               Handles objSMS.QueueVCalendarSent
      If e.ErrorCode > 0 Then
         MsgBox("vCalendar message sending FAILED to: " & e.DestinationNumber & _
               vbCrLf & "[ERROR: " & e.ErrorDescription & _
               "]" & vbCrLf & "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Critical, "VCALENDAR FAILED")
      Else
         MsgBox("vCalendar message SENT to: " & e.DestinationNumber & vbCrLf & _
               "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Information, "VCALENDAR SENT")
      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.QueueVCalendarSending +=
         new mCore.SMS.QueueVCalendarSendingEventHandler
         (objSMS_QueueVCalendarSending);

      objSMS.QueueVCalendarSent +=
         new mCore.SMS.QueueVCalendarSentEventHandler
         (objSMS_QueueVCalendarSent);
   }

   public static void SendQueue()
   {
      mCore.vCalendar objVCAL = objSMS.vCalendar();
      string strVCSFile = "c:\meeting.vcs";
      string strKey = "";
      try
      {

         SetCommParameters();

         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.High);
         MessageBox.Show("vCalendar message added to queue.\r\n" +
                  "[Queue Key: " + strKey + "]");

         objVCAL.Destination = "+919810098765";
         //Following message is sent with normal queue priority
         strKey = objVCAL.SendFileToQueue(strVCSFile);
         MessageBox.Show("vCalendar message added to queue.\r\n" +
                  "[Queue Key: " + strKey + "]");

         objVCAL.Destination = "+919811045678";
         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.Low);
         MessageBox.Show("vCalendar message added to queue.\r\n" +
                  "[Queue Key: " + strKey + "]");

         //Message queue is enabled
         objSMS.Queue.Enabled = true;

         //Messages can be added to the queue even
         //when the Message queue is enabled
         objVCAL.Destination = "+919873012345";
         strKey = objVCAL.SendFileToQueue(strVCSFile, mCore.QueuePriority.High);
         MessageBox.Show("vCalendar message added to queue.\r\n" +
                  "[Queue Key: " + strKey + "]");
      }

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

   //Event at the start of sending a queued vCalendar message
   private void objSMS_QueueVCalendarSending
      (object sender, mCore.QueueVCalendarSendingEventArgs e)
   {
      MessageBox.Show("Sending vCalendar message to: " + e.DestinationNumber + "/r/n" +
            "[Queue Key: " + e.QueueMessageKey + "]");
   }

   //Event at the end of sending a queued vCalendar message
   private void objSMS_QueueVCalendarSent
      (object sender, mCore.QueueVCalendarSentEventArgs e)
   {
      if (e.ErrorCode > 0)
      {
         MessageBox.Show("vCalendar message sending FAILED to: " + e.DestinationNumber +
               "/r/n" + "[ERROR: " + e.ErrorDescription + _
               "]/r/n[Queue Key: " & e.QueueMessageKey + "]");
      }
      else
      {
         MessageBox.Show("vCalendar message SENT to: " + e.DestinationNumber +
               "/r/n" + "[ERROR: " + e.ErrorDescription + _
               "]/r/n[Queue Key: " & e.QueueMessageKey + "]");
      }
   }

   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.vCalendar Method
vCalendar.Destination Property
mCore.SMS.QueueVCalendarSending Event
mCore.SMS.QueueVCalendarSent Event

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved