mCore™ .NET SMS Library 1.2

vCard.SendFileToQueue Method

Description:

The SendFileToQueue method reads the specified vCard file (.vcf 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)

Exceptions:

mCore.vCardException
mCore.GeneralException

Overload List:

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

Remarks:

Usage Example:

Visual Basic

Public Class MyClass
   Public WithEvents objSMS As New mCore.SMS
   Public Sub SendQueue()
      Dim objVCARD As mCore.vCard = objSMS.vCard
      Dim strKey As String
      Dim strVCardFile = "c:\john doe.vcf"
      Try
         SetCommParameters()

         objVCARD.Destination = "+919873094767"

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

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

         objVCARD.Destination = "+919811045678"
         strKey = objVCARD.SendFileToQueue(strVCardFile, mCore.QueuePriority.Low)
         MsgBox("vCard 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

         objVCARD.Destination = "+919873012345"
         strKey = objVCARD.SendFileToQueue(strVCardFile, mCore.QueuePriority.High)
         MsgBox("vCard 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 vCard message
   Private Sub objSMS_QueueVCardSending(ByVal sender As Object, _
               ByVal e As mCore.QueueVCardSendingEventArgs) _
               Handles objSMS.QueueVCardSending
      MsgBox("Sending vCard message to: " & e.DestinationNumber & vbCrLf & _
            "[Queue Key: " & e.QueueMessageKey & _
            "]", MsgBoxStyle.Information, "SENDING VCARD")
   End Sub

   'Event at the end of sending a queued vCard message

   Private Sub objSMS_QueueVCardSent(ByVal sender As Object, _
               ByVal e As mCore.QueueVCardSentEventArgs) _
               Handles objSMS.QueueVCardSent
      If e.ErrorCode > 0 Then
         MsgBox("vCard message sending FAILED to: " & e.DestinationNumber & _
               vbCrLf & "[ERROR: " & e.ErrorDescription & _
               "]" & vbCrLf & "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Critical, "VCARD FAILED")
      Else
         MsgBox("vCard message SENT to: " & e.DestinationNumber & vbCrLf & _
               "[Queue Key: " & e.QueueMessageKey & _
               "]", MsgBoxStyle.Information, "VCARD 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.QueueVCardSending +=
         new mCore.SMS.QueueVCardSendingEventHandler
         (objSMS_QueueVCardSending);

      objSMS.QueueVCardSent +=
         new mCore.SMS.QueueVCardSentEventHandler
         (objSMS_QueueVCardSent);
   }

   public static void SendQueue()
   {
      mCore.vCalendar objVCAL = objSMS.vCalendar();
      string strKey = "";
      string strVCardFile = "c:\john doe.vcf";
      try
      {

         SetCommParameters();

         objVCARD.Destination = "+919873094767";

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

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

         objVCARD.Destination = "+919811045678";
         strKey = objVCARD.SendFileToQueue(strVCardFile, mCore.QueuePriority.Low);
         MessageBox.Show("vCard 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 = objVCARD.SendFileToQueue(strVCardFile, mCore.QueuePriority.High);
         MessageBox.Show("vCard 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_QueueVCardSending
      (object sender, mCore.QueueVCardSendingEventArgs e)
   {
      MessageBox.Show("Sending vCard message to: " + e.DestinationNumber + "/r/n" +
            "[Queue Key: " + e.QueueMessageKey + "]");
   }

   //Event at the end of sending a queued vCard message
   private void objSMS_QueueVCardSent
      (object sender, mCore.QueueVCardSentEventArgs e)
   {
      if (e.ErrorCode > 0)
      {
         MessageBox.Show("vCard message sending FAILED to: " + e.DestinationNumber +
               "/r/n" + "[ERROR: " + e.ErrorDescription + _
               "]/r/n[Queue Key: " & e.QueueMessageKey + "]");
      }
      else
      {
         MessageBox.Show("vCard 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.vCard Method
vCard.Destination Property
mCore.SMS.QueueVCardSending Event
mCore.SMS.QueueVCardSent Event

 

Copyright © IG Logix Softech Pvt Ltd, All Rights Reserved