private void SendMultiple(OutgoingSmsPdu[] pdus) { var num = pdus.Length; try { // Send the created messages comm.EnableTemporarySmsBatchMode(); foreach (OutgoingSmsPdu pdu in pdus) { comm.SendMessage(pdu); } } catch { } }
public bool Send(System.Collections.ArrayList messageList, bool chkAlert, bool chkUnicode) { bool retValue = true; try { // If SMS batch mode should be activated, do it before sending the first message if (messageList.Count > 1) { comm.EnableTemporarySmsBatchMode(); } // Send an SMS message SmsSubmitPdu pdu; bool alert = chkAlert; bool unicode = chkUnicode; string smsc = string.Empty; SmsModule.Message msg = null; for (int count = 0; count < messageList.Count; count++) { msg = (Message)messageList[count]; if (!alert && !unicode) { // The straightforward version pdu = new SmsSubmitPdu(msg.Text, msg.PhoneNumber, smsc); } else { // The extended version with dcs byte dcs; if (!alert && unicode) { dcs = DataCodingScheme.NoClass_16Bit; } else if (alert && !unicode) { dcs = DataCodingScheme.Class0_7Bit; } else if (alert && unicode) { dcs = DataCodingScheme.Class0_16Bit; } else { dcs = DataCodingScheme.NoClass_7Bit; // should never occur here } pdu = new SmsSubmitPdu(msg.Text, msg.PhoneNumber, smsc, dcs); } // Send the message the specified number of times comm.SendMessage(pdu); System.Threading.Thread.Sleep(2000); } } catch (Exception ex) { throw ex; } return(retValue); }
private void btnSend_Click(object sender, EventArgs e) { Cursor.Current = Cursors.WaitCursor; try { // Send an SMS message SmsSubmitPdu pdu; bool alert = chkAlert.Checked; bool unicode = chkUnicode.Checked; string smsc = chkSMSC.Checked ? txtSMSC.Text : string.Empty; if (!alert && !unicode) { // The straightforward version pdu = new SmsSubmitPdu(txtMessage.Text, txtNumber.Text, smsc); } else { // The extended version with dcs byte dcs; if (!alert && unicode) { dcs = DataCodingScheme.NoClass_16Bit; } else if (alert && !unicode) { dcs = DataCodingScheme.Class0_7Bit; } else if (alert && unicode) { dcs = DataCodingScheme.Class0_16Bit; } else { dcs = DataCodingScheme.NoClass_7Bit; // should never occur here } pdu = new SmsSubmitPdu(txtMessage.Text, txtNumber.Text, smsc, dcs); } // If a status report should be generated, set that here pdu.RequestStatusReport = true; // If SMS batch mode should be activated, do it before sending the first message comm.EnableTemporarySmsBatchMode(); // No. of Recipients int Recipients = 0; // Send the message the specified number of times for (int i = 0; i < Recipients; i++) { comm.SendMessage(pdu); Output("Message {0} of {1} sent.", i + 1, Recipients); Output(""); } } catch (Exception ex) { ShowException(ex); } Cursor.Current = Cursors.Default; }