Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My application in c# is sending message on a single mobile number which i enter in text box.... i am using mysql database i want that sms should send to all mobile numbers which are present in the field of "cellno" in my sql database, my code is working for single number how can i send it on more than one mobile...?
Posted
Comments
ZurdoDev 13-Apr-12 10:11am    
Loop through the records in the db and call the same code you are using now and just replace the number.

You will have to send a separate message for each number, I think. So either loop around the list of numbers creating requests, or use a parallel approach and spawn a task to send a message to each number on the whole list.
 
Share this answer
 
As much as I hate how this sounds.....

Ever hear of a "for" loop?

C#
for (int i =0; i < number of contacts; i++)
{
  sendMsg(port, p, p1);
}



But it does not sound like a legitimate type of program to me.... spamming cell phones.
 
Share this answer
 
seperate mobile numbers with comas(,) most probably your problem will be solved
 
Share this answer
 
i am using this code....... if i make a string for retrieving cell numbers from database and then put this string istead of p(textbox) then is it right way?

public bool sendMsg(SerialPort port,string p, string p1)
{

bool isSend = false;

string recievedData = ExecCommand(port, "AT", 300, "No phone connected");
recievedData = ExecCommand(port, "AT+CMGF=0", 300, "Failed to set message format.");

string command ="AT+CMGS=\"" + p + "\"";

recievedData = ExecCommand(port, command, 300, "Failed to accept phoneNo");
string command1 = "AT+CMGS=\"14" + p1 + char.ConvertFromUtf32(26) + "\r";


recievedData = ExecCommand(port,command1, 5000, "Failed to send message"); //3 seconds
if (recievedData.EndsWith("\r\nOK\r\n"))
{
isSend = true;
}
else if (recievedData.Contains("ERROR"))
{
isSend = false;
}
return isSend;
}
 
Share this answer
 
Comments
wizardzz 13-Apr-12 14:17pm    
Yes, that sounds about right, in logic, didn't look at your code though.
i need code or psudo code for solution
 
Share this answer
 
Comments
wizardzz 13-Apr-12 14:16pm    
Edit your question, don't post as answer.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900