How send the sms on mobile number which is save on SIM card inseted in sketch

I need some help regarding GSM module to send the sms and get the contact detail from SIM card.

I can search the contact on SIM card with
“AT+CPBS=“SM”” and “AT+CPBF=“Aarduino””

AT command return “+CPBF: 1,”+XXXXXXXXXXXX",145,“Arduino”" // Mobile number save with name of Arduino

Now I want to use return number from AT command and send sms on this number.

#include "SIM900.h"
#include <SoftwareSerial.h>
#include "sms.h"
SMSGSM sms;

boolean started=false;

void setup()
{
  //Serial connection.
  Serial.begin(9600);
  Serial.println("GSM Shield testing.");
  if (gsm.begin(2400)) {
    Serial.println("\nstatus=READY");
    started = true;
  } else Serial.println("\nstatus=IDLE");

  if (started) {
    gsm.SimpleWriteln("AT+CPBS=\"SM\"");
    delay(2000);
    gsm.SimpleWriteln("AT+CPBF=\"Aarduino\"");
    delay(2000);
    if (sms.SendSMS("+XXXXXXXXXX", "Arduino SMS"))
      Serial.println("\nSMS sent OK");
  }
}

void loop()
{

}

Serial monitor :

+CPBF: 1,"+XXXXXXXXXXXX",145,"Arduino"

OK

> 
DEBUG:>
ATT: +CMGS
RIC: 
+CMGS: 120

OK

SMS sent OK

any help

I can search the contact on SIM card with
“AT+CPBS=“SM”” and “AT+CPBF=“Aarduino””

So, when you misspell Arduino, it still finds the correct number. Interesting.

I can’t see anything in your code that reads anything from the modem, so I don’t see how you intend to know what the reply from the AT command was. Without having the reply to parse, you’re going to have a very difficult time parsing anything.

PaulS: So, when you misspell Arduino, it still finds the correct number. Interesting.

Sorry, its may be mistake during typing or may be auto spell correction. I save the contact on sim card with name Aarduino and reason of "Aa" make 1st number on SIM card. With "AT+CPBF=\"Aarduino\"" Search the name in sim contact and return same number on serial monitor.

With "AT+CPBF=\"Aarduino\"" Search the name in sim contact and return same number on serial monitor.

The modem returns a reply, which goes in one ear (serial port) and out the other, without making any impression.

If it DID make an impression (get stored), then you COULD parse the stored data, and extract (and use) the phone number.

Still getting the same result in Serial output. Can anyone help to extract the +XXXXXXXXXXX

String textMessage = "";


String readString, substring;
int loc;


  if (SIM900.available() > 0) {
    textMessage = SIM900.readString();
    delay(10);
  }
  SIM900.println("AT+CPBF=\"Aarduino\"");
  delay(1000);
  Serial.println(textMessage);

  if (textMessage == '"') {
    Serial.println(readString); //prints string to serial port out
    loc = readString.indexOf("");
    substring = readString.substring(loc + 0, loc + 13);
    Serial.print("date is: ");
    Serial.println(substring);

    readString = "";
    substring = "";
  }
  else {
    readString += textMessage; 
  }

Serial output

AT+CPBF="Aarduino"

+CPBF: 1,"+XXXXXXXXXXX",145,"Aarduino