Click here to Skip to main content
14,210,839 members
Rate this:
Please Sign up or sign in to vote.
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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 4

As much as I hate how this sounds.....

Ever hear of a "for" loop?

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 5

seperate mobile numbers with comas(,) most probably your problem will be solved
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

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;
}
   
Comments
wizardzz 13-Apr-12 14:17pm
   
Yes, that sounds about right, in logic, didn't look at your code though.
Rate this:
Please Sign up or sign in to vote.

Solution 3

i need code or psudo code for solution
   
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)



Advertise | Privacy | Cookies | Terms of Service
Web04 | 2.8.190618.1 | Last Updated 16 Apr 2012
Copyright © CodeProject, 1999-2019
All Rights Reserved.
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100