Tech
News
Videos
Forums
Jobs
Books
Events
More
Interviews
Live
Learn
Training
Career
Members
Blogs
Challenges
Certification
Contribute
Article
Blog
Video
Ebook
Interview Question
.NET
.NET Core
.NET MAUI
.NET Standard
Active Directory
ADO.NET
Agile Development
AI
AJAX
AlbertAGPT
Alchemy
Alexa Skills
Algorand
Algorithms in C#
Android
Angular
ArcObject
ASP.NET
ASP.NET Core
Augmented Reality
Avalanche
AWS
Azure
Backbonejs
Big Data
BizTalk Server
Blazor
Blockchain
Bootstrap
Bot Framework
Business
Business Intelligence(BI)
C#
C# Corner
C# Strings
C, C++, MFC
Career Advice
Careers and Jobs
Chapters
ChatGPT
Cloud
Coding Best Practices
Cognitive Services
COM Interop
Compact Framework
Copilot
Cortana Development
Cosmos DB
Cryptocurrency
Cryptography
Crystal Reports
CSS
Current Affairs
Custom Controls
Cyber Security
Data Mining
Data Science
Databases & DBA
Databricks
Design Patterns & Practices
DevExpress
DevOps
DirectX
Dynamics CRM
Enterprise Development
Entity Framework
Error Zone
Exception Handling
F#
Files, Directory, IO
Flutter
Games Programming
GDI+
General
Generative AI
GO
Google Cloud
Google Development
Graphics Design
Graphite Studio
Hardware
Hiring and Recruitment
HoloLens
How do I
HTML 5
Infragistics
Internet & Web
Internet of Things
Ionic
Java
Java and .NET
JavaScript
JQuery
JSON
JSP
Knockout
Kotlin
Langchain
Leadership
Learn .NET
Learn iOS Programming
LINQ
Machine Learning
Metaverse
Microsoft 365
Microsoft Fabric
Microsoft Office
Microsoft Phone
Microsoft Teams
Mobile Development
MongoDB
MuleSoft
MySQL
NEAR
NetBeans
Networking
NFT
NoCode LowCode
Node.js
Office Development
OOP/OOD
Open Source
Operating Systems
Oracle
Outsourcing
Philosophy
PHP
Polygon
PostgreSQL
Power Apps
Power Automate
Power BI
Power Pages
Printing in C#
Products
Progress
Progressive Web Apps
Project Management
Public Speaking
Python
Q#
QlikView
Quantum Computing
R
React
React Native
Reports using C#
Robotics & Hardware
RPA
Ruby on Rails
RUST
Salesforce
Security
Servers
ServiceNow
SharePoint
Sharp Economy
SignalR
Smart Devices
Snowflake
Software Architecture/Engineering
Software Testing
Solana
Solidity
Sports
SQL
SQL Server
Startups
Stratis Blockchain
Swift
SyncFusion
Threading
Tools
TypeScript
Unity
UWP
Visual Basic .NET
Visual Studio
Vue.js
WCF
Wearables
Web API
Web Design
Web Development
Web3
Windows
Windows Controls
Windows Forms
Windows PowerShell
Windows Services
Workflow Foundation
WPF
Xamarin
XAML
XML
XNA
XSharp
Register
Login
2
Answers
sending sms to many numbers using gsm modem in c#
Ahmet Taha
3y
1k
1
Reply
Hello Guyz, i would like to ask how can i send sms to all number attached here is my source code i can only sent a sms to one phone number but i want to send it to many phone number. thanks
using
System;
using
System.Collections.Generic;
using
System.ComponentModel;
using
System.Data;
using
System.Drawing;
using
System.Linq;
using
System.Text;
using
System.Windows.Forms;
using
System.Data.SqlClient;
//============
using
System.IO.Ports;
using
System.Threading;
namespace
StudentInformationSystem
{
public
partial
class
frmsendingsms : Form
{
SqlCommand cmd;
SqlConnection cn;
SqlDataAdapter da;
SqlDataReader dr;
string
_title =
"STUDENT INFORMATION SYSTEM"
;
public
frmsendingsms()
{
InitializeComponent();
academicyear();
}
public
void
academicyear()
{
cn = ClassDB.ConnectDB();
//cn.Open();
cmd =
new
SqlCommand(
"select academicyear from tblAY where status like 'OPEN'"
, cn);
cmd.Parameters.AddWithValue(
"@academicyear"
, txtacademicyear.Text);
dr = cmd.ExecuteReader();
dr.Read();
if
(dr.HasRows)
{
txtacademicyear.Text = dr[
"academicyear"
].ToString();
// txtacademicterm.Text = dr["term"].ToString();
//cbacademicterm.Text = dr["term"].ToString();
}
else
{
}
dr.Close();
cn.Close();
}
private
void
btnSend_Click(
object
sender, EventArgs e)
{
try
{
SerialPort sp =
new
SerialPort();
sp.PortName = cbportnumber.Text;
sp.Open();
sp.WriteLine(
"AT"
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(
"AT+CMGF=1"
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(
"AT+CMGS=\""
+ txtPhoneNumber.Text +
"\""
+ Environment.NewLine);
Thread.Sleep(100);
sp.WriteLine(txtMessage.Text + Environment.NewLine);
Thread.Sleep(100);
sp.Write(
new
byte
[] { 26 }, 0, 1);
Thread.Sleep(100);
var response = sp.ReadExisting();
if
(response.Contains(
"ERROR"
))
MessageBox.Show(
"Send failed!"
,
"Message"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
else
MessageBox.Show(
"Message has been sent"
,
"Message"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
sp.Close();
}
catch
(Exception ex)
{
MessageBox.Show(ex.Message,
"Message"
, MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
private
void
txtyear1_TextChanged(
object
sender, EventArgs e)
{
try
{
txtyear2.Text = (
long
.Parse(txtyear1.Text) + 1).ToString();
}
catch
{
txtyear2.Clear();
}
txtacademicyear.Text = txtyear1.Text +
"-"
+ txtyear2.Text;
}
private
void
txtsearch_KeyUp(
object
sender, KeyEventArgs e)
{
cn = ClassDB.ConnectDB();
listBox1.Visible =
true
;
listBox1.Items.Clear();
SqlCommand cmd = cn.CreateCommand();
cmd.CommandType = CommandType.Text;
cmd =
new
SqlCommand(
"Select* from tblstudentregistration where lrn like'"
+ txtsearch.Text +
"%' or fullname Like '"
+ txtsearch.Text +
"%'"
, cn);
cmd.ExecuteNonQuery();
DataTable dt =
new
DataTable();
SqlDataAdapter da =
new
SqlDataAdapter(cmd);
da.Fill(dt);
foreach
(DataRow dr
in
dt.Rows)
{
listBox1.Items.Clear();
listBox1.Items.Add(dr[
"lrn"
]).ToString();
// listBox1.Items.Clear();
listBox1.Items.Add(dr[
"fullname"
]).ToString();
}
}
private
void
txtsearch_KeyDown(
object
sender, KeyEventArgs e)
{
try
{
cn = ClassDB.ConnectDB();
if
(e.KeyCode == Keys.Down)
{
listBox1.Focus();
listBox1.SelectedIndex = 0;
}
}
catch
(Exception ex)
{
MessageBox.Show(ex.ToString());
}
}
private
void
listBox1_KeyDown(
object
sender, KeyEventArgs e)
{
cn = ClassDB.ConnectDB();
if
(e.KeyCode == Keys.Down)
{
this
.listBox1.SelectedIndex =
this
.listBox1.SelectedIndex;
}
if
(e.KeyCode == Keys.Up)
{
this
.listBox1.SelectedIndex =
this
.listBox1.SelectedIndex;
}
if
(e.KeyCode == Keys.Enter)
{
//search();
txtsearch.Text = listBox1.SelectedItem.ToString();
displayresulttextboxs();
// displayresultontxtboxes();
listBox1.Visible =
false
;
}
}
private
void
displayresulttextboxs()
{
cn = ClassDB.ConnectDB();
// cmd = new SqlCommand("Select * from tblstudentregistration where lrn='" + txtsearchstudentlrn0rFullname.Text + "' and academicyear='" + txtacademicyear.Text + "' and academicterm='" + txtacademicterm.Text + "'", cn);
cmd =
new
SqlCommand(
"Select * from tblstudentregistration where lrn='"
+ txtsearch.Text +
"' and academicyear='"
+txtacademicyear.Text+
"' and academicterm ='"
+cbacademicterm.Text+
"'"
, cn);
dr = cmd.ExecuteReader();
if
(dr.Read())
{
txtsearch.Text = dr[1].ToString();
txtPhoneNumber.Text= dr[9].ToString();
}
else
{
cn = ClassDB.ConnectDB();
// cmd = new SqlCommand("Select * from tblstudentregistration where fullname='" + txtsearchstudentlrn0rFullname.Text + "' and academicyear='" + txtacademicyear.Text + "' and academicterm='" + txtacademicterm.Text + "'", cn);
cmd =
new
SqlCommand(
"Select * from tblstudentregistration where fullname='"
+ txtsearch.Text +
"' and academicyear='"
+ txtacademicyear.Text +
"' and academicterm ='"
+ cbacademicterm.Text +
"'"
, cn);
dr = cmd.ExecuteReader();
if
(dr.Read())
{
txtsearch.Text = dr[1].ToString();
txtPhoneNumber.Text = dr[9].ToString();
}
else
{
MessageBox.Show(
"There's no Record has been found"
, _title, MessageBoxButtons.OK, MessageBoxIcon.Stop);
}
}
}
private
void
btnsearch_Click(
object
sender, EventArgs e)
{
}
}
}
Post
Reset
Cancel
Answers (
2
)
Next Recommended Forum
Email Address Validation @ is not working cshtml
how to change the css for Upload Control in asp.net?