2

I want to develop a simple app that enables me to send SMS to several numbers and from several numbers.

In the code below, I send from number 5555 to 6666. I want to send, for example, also from number 7777 to number 8888.

What do I need to add to the code?

Meanwhile, I tried to copy TextMessage message but without success.

package getstarted;

import com.nexmo.client.NexmoClient;
import com.nexmo.client.auth.AuthMethod;
import com.nexmo.client.auth.TokenAuthMethod;
import com.nexmo.client.sms.SmsSubmissionResult;
import com.nexmo.client.sms.messages.TextMessage;

public class SendSMS {

    public static void main(String[] args) throws Exception {
        AuthMethod auth = new TokenAuthMethod("xxxxx","yyyy");
        NexmoClient client = new NexmoClient(auth);

        TextMessage message = new TextMessage("5555", "6666", "Hello from Nexmo!");
        SmsSubmissionResult[] responses = client.getSmsClient().submitMessage(message);

        for (SmsSubmissionResult response : responses) {
            System.out.println(response);
        }
    }
}
blurfus
  • 13,485
  • 8
  • 55
  • 61
shani
  • 21
  • 3
  • [Welcome to StackOverflow](http://StackOverflow.com/tour) - Please read our [ask] page and edit your question to improve it. Good questions tend to receive quick, better answers from the community. – blurfus Jul 11 '19 at 18:44

1 Answers1

2

Just instantiate another TextMessage:

TextMessage message2 = new TextMessage("7777", "8888", "Hello from Nexmo!");
SmsSubmissionResult[] responses2 = client.getSmsClient().submitMessage(message2);

for (SmsSubmissionResult response : responses2) {
    System.out.println(response);
}
nLee
  • 1,320
  • 2
  • 10
  • 21