Note that there are some explanatory texts on larger screens.

plurals
  1. POSending SMS Through Serial port in c#
    primarykey
    data
    text
    <p>I am using Serial port to send sms through a GSM/Modem .My code is working with single sms. The problem arise when I try to send sms in bulk. Then no sms are sent and no exceptions are generated.</p> <pre><code> using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO.Ports; using System.ComponentModel; using System.Windows.Forms; namespace program.cs { public class Class1 { public string[] strarray = new string[10]; SerialPort serialport1 = new SerialPort(); string com = "COM8"; int mybaudrate = 9600; //this.strarray =System.IO.Ports.SerialPort.GetPortNames(); public void getports() { this.strarray = System.IO.Ports.SerialPort.GetPortNames(); } public bool connetport() { bool Isopen; serialport1.Close(); try { if (!this.serialport1.IsOpen) { this.serialport1.PortName = com; this.serialport1.Open(); this.serialport1.BaudRate = mybaudrate; this.serialport1.StopBits = System.IO.Ports.StopBits.One; this.serialport1.Parity = System.IO.Ports.Parity.None; this.serialport1.Handshake = System.IO.Ports.Handshake.None; Isopen= serialport1.IsOpen; } Isopen = true; } catch (Exception ex) { Isopen = false; throw ex; } return Isopen; } public void sendsms() { try { if (this.serialport1.IsOpen) { // to send bulk sms serialport1.BaseStream.Flush(); int loop = 0; int howmany = 0; howmany = 200; while (loop &lt; howmany) { System.Threading.Thread.Sleep(3500); string cb = char.ConvertFromUtf32(26); this.serialport1.Write("AT+CMGF=1\r"); this.serialport1.Write("AT+CSCA=servicecenter\r \n");//Ufone Service Center this.serialport1.Write("AT+CMGS=\"" + "03468916446" + "\"\r\n");// this.serialport1.Write("hello" + cb);//message text message sending System.Threading.Thread.Sleep(3500); loop++; } MessageBox.Show("Message Sent Number" + loop); serialport1.Close(); } } catch (Exception ex) { serialport1.Close(); throw ex; } } } </code></pre> <p>}</p> <p>Class1 above is used to connect and send sms</p> <p><br> Code For Main Program<br></p> <pre><code>public partial class Form1 : Form { public Form1() { InitializeComponent(); } bool check; Class1 obj = new Class1(); private void button1_Click(object sender, EventArgs e) { check = obj.connetport(); MessageBox.Show("Connecton Status" + check); obj.sendsms(); MessageBox.Show("have completed"); } } </code></pre> <p>I have invested a lot of time on solving this problem but without success. Your help will be appreciated </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload