Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#2.0 C# Application
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.
 
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 9-Dec-11 21:07pm
N10K1.7K
Edited 15-Dec-11 9:52am
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 1

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.
  Permalink  
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add Notification (Enable):
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:
if (chkReport.Checked)
  pdu.RequestStatusReport = true;
 
Show Output of Status:
 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);
            }
        }
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 299
1 Maciej Los 295
2 Sergey Alexandrovich Kryukov 230
3 Aajmot Sk 191
4 Sinisa Hajnal 166
0 OriginalGriff 7,760
1 Sergey Alexandrovich Kryukov 7,072
2 DamithSL 5,604
3 Manas Bhardwaj 4,986
4 Maciej Los 4,785


Advertise | Privacy | Mobile
Web04 | 2.8.1411023.1 | Last Updated 28 Dec 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100