Click here to Skip to main content
15,883,809 members
Please Sign up or sign in to vote.
5.00/5 (2 votes)
See more:
Hi,

I'm creating C# windows Application. In that application i used GSM Library.
my application has working fined but i can't get any delivery report.


the code is follows....

In my application i'm using following

pdu.RequestStatusReport = true; // here i hv to set SMS status report ture.
CommSetting.comm.SendMessage(pdu);
// here i hv to check sms is delivered to recipient or not, if received then my DB table Flags invoked.
SmsDeliverMessageFlags sdmf = new SmsDeliverMessageFlags();
string DeliverRpt = sdmf.MessageType.ToString();



This is my function and code using my application.

C#
try
            {
                OleDbConnection olecon2 = new OleDbConnection(accessConStr);
                string query = "SELECT TOP 5 id, mbno, msg, SchedDate FROM SMS WHERE Flag = False and SchedDate < #" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "# and DateDiff('n',SchedDate ,#" + DateTime.Now.ToString("MM/dd/yyyy hh:mm:ss tt") + "#) < 30";
                OleDbCommand oleCmd = new OleDbCommand(query, olecon2);
                OleDbDataReader oleDr = null;
                olecon2.Open();
                oleDr = oleCmd.ExecuteReader();
                while (oleDr.Read())
                {
                    string id = oleDr["id"].ToString();
                    string MbNo = oleDr["mbno"].ToString();
                    string MbMsg = oleDr["msg"].ToString();

                    if (MbNo != null && MbMsg != "")
                    {
                        Cursor.Current = Cursors.WaitCursor;

                        try
                        {
                            // Send an SMS message
                            SmsSubmitPdu pdu;
                            pdu = new SmsSubmitPdu(MbMsg, MbNo, "");  // "" indicate SMSC No
                            pdu.RequestStatusReport = true;
                            CommSetting.comm.SendMessage(pdu);

                            SmsDeliverMessageFlags sdmf = new SmsDeliverMessageFlags();
                            string DeliverRpt = sdmf.MessageType.ToString();
<big>// Here i want to get Delivery Report. After getting SMS.</big>
                            if (DeliverRpt == "SmsDeliver")
                            {
                                OleDbConnection olecon3 = new OleDbConnection(accessConStr);
                                string query2 = "Update [tbl_SMS] SET [Flag] = true, [Date]= '" + DateTime.Now.ToString() + "' Where [MobileNo] = " + MbNo + " and [id] = '" + id + "' ";
                                OleDbCommand cmd2 = new OleDbCommand(query2, olecon3);
                                olecon3.Open();
                                cmd2.ExecuteNonQuery();
                                olecon3.Close();
                                err.ErrorLog("Id : " + id + " Mobile No : " + MbNo + " Message : Message Delivered SuccessFully...!!  ");
                            }
                        }
                        catch (Exception ex)
                        {
                            MessageBox.Show(ex.Message);
                        }
                        Cursor.Current = Cursors.Default;
                    }
                }
                oleDr.Close();
                olecon2.Close();
            }
            catch (Exception erg)
            {
                err.ErrorLog("In Error => SMSSTATUS GridView Loading : " + erg.Message);
            }




if any one use GSM Library in SMS c# windows Application thn plz tell me how can i get delivery report when my sms is received recipeint.



thnxx for advance
Posted
Updated 15-Dec-11 8:52am
v2

The carriers that the sender and receiver are using must also support delivery reports. If one carrier doesn't support it, you're not getting a report no matter what you do.
 
Share this answer
 
Add Notification (Enable):
C#
private void btnEnableNotification_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                // Enable notifications about new received messages
                if (!registerMessageReceived)
                {
                    comm.MessageReceived += new MessageReceivedEventHandler(comm_MessageReceived);
                    registerMessageReceived = true;
                }
                comm.EnableMessageNotifications();
                Output("Message notifications activated.");
                Output("");
            }
            catch (Exception ex)
            {
                ShowException(ex);
            }

            Cursor.Current = Cursors.Default;
        }


Add RequestStatusReport True:
C#
if (chkReport.Checked)
  pdu.RequestStatusReport = true;


Show Output of Status:
C#
private void comm_MessageReceived(object sender, MessageReceivedEventArgs e)
       {
           try
           {
               IMessageIndicationObject obj = e.IndicationObject;
               if (obj is MemoryLocation)
               {
                   MemoryLocation loc = (MemoryLocation)obj;
                   Output(string.Format("New message received in storage \"{0}\", index {1}.",
                   loc.Storage, loc.Index));
                   Output("");
                           return;
               }

               Output("Error: Unknown notification object!");
           }
           catch (Exception ex)
           {
               ShowException(ex);
           }
       }
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900