class MyClass
{
public mCore.SMS objSMS = new mCore.SMS();
public MyClass()
{
objSMS.QueueWapPushSending +=
new mCore.SMS.QueueWapPushSendingEventHandler
(objSMS_QueueWapPushSending);
objSMS.QueueWapPushSent +=
new mCore.SMS.QueueWapPushSentEventHandler
(objSMS_QueueWapPushSent);
}
public static void SendQueue()
{
mCore.WapPush objWP = objSMS.WapPush();
string strKey = "";
try
{
SetCommParameters();
objWP.Destination =
"+919873094767";
objWP.Text = "Check
your emails online";
objWP.URL = "http://www.mobulus.com/mobile";
objWP.Action =
mCore.WapPush.EnumAction.SignalMedium;
objWP.Created =
DateTime.Now;
objWP.Expiry = "1W";
if (objWP.IsLengthOK)
{
strKey = objVCAL.SendToQueue(mCore.QueuePriority.High);
MessageBox.Show("vCalendar
message
added to queue.\r\n" +
"[Queue Key: " + strKey + "]");
}
objWP.Destination =
"+919810098765";
if (objWP.IsLengthOK)
{
//Following message is sent with normal queue priority
strKey =
objWP.SendToQueue();
MessageBox.Show("WAP
Push
message added
to queue.\r\n" +
"[Queue Key: " + strKey + "]");
}
objWP.Destination =
"+919811045678";
if (objWP.IsLengthOK)
{
strKey =
objWP.SendToQueue(mCore.QueuePriority.Low);
MessageBox.Show("WAP
Push
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
objWP.Destination =
"+919873012345";
if (objWP.IsLengthOK)
{
strKey =
objWP.SendToQueue(mCore.QueuePriority.High);
MessageBox.Show("WAP
Push
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
WAP Push message
private void objSMS_QueueWapPushSending
(object sender, mCore.QueueWapPushSendingEventArgs e)
{
MessageBox.Show("Sending WAP Push message to: " + e.DestinationNumber + "/r/n" +
"[Queue Key:
" + e.QueueMessageKey + "]");
}
//Event at the end of sending a queued
WAP Push message
private void objSMS_QueueWapPushSent
(object sender, mCore.QueueWapPushSentEventArgs e)
{
if (e.ErrorCode > 0)
{
MessageBox.Show("WAP Push
message sending FAILED to: " + e.DestinationNumber +
"/r/n" + "[ERROR: " + e.ErrorDescription + _
"]/r/n[Queue
Key: " & e.QueueMessageKey + "]");
}
else
{
MessageBox.Show("WAP Push
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)
{
}
}
} |