C# application to send SMS

Jan 5 2016 8:38 PM
Please can anyone find the error in this code. 
Connecting to the port is OK, but the SMS doesn't send.
 
//Connecting to port
//__________________________________________________________________________________________________________________________
private void button1_Click_1(object sender, EventArgs e)
{
if (txtComPort.Text == "")
{
MessageBox.Show("Invalid port number");
return;
}
comm = new GsmCommMain(txtComPort.Text, 9600, 150);
Cursor.Current = Cursors.Default;
bool retry;
do
{
retry = false;
try{
Cursor.Current = Cursors.WaitCursor;
comm.Open();
Cursor.Current=Cursors.Default;
MessageBox.Show("Connected");
}catch(Exception)
{
Cursor.Current=Cursors.Default;
if(MessageBox.Show(this,"GSM is not available","Check",MessageBoxButtons.RetryCancel,MessageBoxIcon.Warning)==DialogResult.Retry);
}
}
while(retry);
}
//Send SMS
//__________________________________________________________________________________________________________________________
try
{
SmsSubmitPdu pdu;
byte dcs = (byte)DataCodingScheme.GeneralCoding.Alpha7BitDefault;
pdu = new SmsSubmitPdu(txtSMS.Text, txtRecoverTel.Text,dcs);
int time = 1;
for (int i = 0; i < time; i++)
{
comm.SendMessage(pdu);
}
}
catch(Exception)
{
MessageBox.Show("Not availale");
}
 

Answers (3)