How to Send Multiple Sms to Single Number

How to send text message to more than 1 number?

You can't do this via Intent, as the android SMS app doesn't allow multiple recipients.

You can try using the SmsManager class.

First of all you need to request the permission android.permission.SEND_SMS in your AndroidManifest.

Then you can do something along these lines.

// you need to import the Sms Manager
import android.telephony.SmsManager;

// fetch the Sms Manager
SmsManager sms = SmsManager.getDefault();

// the message
String message = "Hello";

// the phone numbers we want to send to
String numbers[] = {"555123456789", "555987654321"};

for(String number : numbers) {
sms.sendTextMessage(number, null, message, null, null);
}



Update: Added how to split a comma-separated string

// string input by a user
String userInput = "122323,12344221,1323442";

// split it between any commas, stripping whitespace afterwards
String numbers[] = userInput.split(", *");

Not able to send sms in loop properly, sending multiple sms to single person by mistake

May be you should add a condition for studentId or StudentNo in this Sql Statement.

using (SqlCommand GetAbsentCmd = new SqlCommand("select mobile from studentattendance where  convert(varchar(10), attdate, 120) = '" + TodaysDate + "' and attendance='Absent'", GetAbsentCon))

Best way to send multiple SMS at one click using SMS Gateway

my solution was this:

--page /sendsms/?phone_nr=1122 sends one sms to phone nr 1122

--page /sendbulk has a loop which calls in php the page /sendsms/?phone_nr=1122 with file function file('http://www.domain.com//sendsms/?phone_nr=' . $phone_nr[$i]);

--the client on submit will call with ajax(no return needed) the page /sendbulk

This way even if the client closes the connection the server will continue to run /sendbulk in background and will send all messages



Related Topics



Leave a reply



Submit