How to send SMS using Android mobile Or GSM Modem

343 Views

Dear viewer we will discuss a very impotent topic sending sms using  mobile phone and GSM modem, most demanding module by client.I have experience developing collection of software we used GSM modem and mobile for sending sms every where.o we developed a small application that runs on the server and sends a SMS whenever a new record is inserted into the database from any client.

  • GSM Modem (I have used Vodafone; you can use any)
  • SIM Card. 
  • Communication Port Settings
  • Receive Incoming Message
  • Send Messages
  • Read All Messages (Sent by the users)
  • Delete Messages (One or All)

I have used the GSMComm Library for Sending and Receiving SMS. You require a GSM modem or phone for sending an SMS.

Dear Reader, please read this carefully in thais step we need to include the following DLL files in the bin\ Debug folder:

  • GSMCommServer.dll
  • GSMCommShared.dll
  • GSMCommunication.dll
  • PDUConverter.dll

C# Code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using GsmComm.PduConverter;
using GsmComm.PduConverter.SmartMessaging;
using GsmComm.GsmCommunication;
using System.Windows.Forms;
using System.IO.Ports;

namespace  MYAPPLICATION
{
public partial class Modem : Form
{
public GsmCommMain comm;
private string myText;
public Modem()
{
InitializeComponent();
getport();
AddLine();
}
void getport()
{
string[] Ports = SerialPort.GetPortNames();
cbcom.Items.AddRange(Ports);
}
public void AddLine()
{
try
{

//if (comm == null)
// {
// var q = (from a in db.tblmodems
// where a.PID == 1
// select a).SingleOrDefault();
// int x = Convert.ToInt16(q.PortNumber);
comm = new GsmCommMain(3, 9600, 300);
Cursor.Current = Cursors.Default;
bool retry;
do
{
retry = false;
try
{
Cursor.Current = Cursors.WaitCursor;
comm.Open();
Cursor.Current = Cursors.Default;
MessageBox.Show(“Connected Sucessfuly”);
myText = comm.ToString();
}
catch (Exception)
{
Cursor.Current = Cursors.Default;
//if (MessageBox.Show(this, “GSM in not Availble”, “Check”,MessageBoxButtons.RetryCancel, MessageBoxIcon.Warning) == DialogResult.Retry)
// retry = true;
//else { return; }
MessageBox.Show(“Device Not Found Connected”);
}
}
while (retry);
//}
//else { MessageBox.Show(“Please Check Device”); }
}
catch (Exception ex)
{ MessageBox.Show(ex.Message, “ERROR”); }
}
private void msg()
{
try
{
SmsSubmitPdu pdu;

byte dcs = (byte)DataCodingScheme.DataCoding.Class0;
pdu = new SmsSubmitPdu(textBox1.Text, “03014865779”, dcs);

int time = 1;
for (int i = 0; i < time; i++)
{
comm.SendMessage(pdu);
}

}
catch
{
MessageBox.Show(“Modem is not availeble”);
}
}
private void button1_Click(object sender, EventArgs e)
{
msg();
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
int lines = textBox1.Lines.Length; // count lines
int chars = textBox1.Text.Length; //count characters
label2.Text = chars.ToString();
}
}
}

 

Note: Please feel free to contact me if you need any further information. Please let me know if you have any questions.

Like Our Facebook page

https://www.facebook.com/Nayiweb/

ask your question via Facebook Messenger

Thanks

 

Skip to toolbar