GSM Sheild

Good morning,

I am working with Arduino GSM shield linked below with the Arduino mega.
I am using 5 volts, 2 A power supply.
I added a jumper between pin 2 and 10.

When I use send SendSMS from Arduino library, it works fine.
However, when I integrate the SendSMS code to the another project, I get an error.
The message is not sent.

Any help is appreciated

 ////////////////////////////////GSM
#include <GSM.h>
#define PINNUMBER ""
GSM gsmAccess(true); 
GSM_SMS sms;

int x =0;
int Send = 2;
char remoteNum2[11] = "0503361036";  // telephone number to send sms
char txtMsg[200] = " Total time is";
int DoorOpen = 0;

GSMVoiceCall vcs;
String remoteNumber = "0503361036";  // the number you will call
char charbuffer[20];




/////////////////////////////

unsigned long interval_S1=0;
unsigned long pre_time_S1=0;
unsigned long time_S1=0;

unsigned long interval_S2=0;
unsigned long pre_time_S2=0;
unsigned long time_S2=0;

unsigned long interval_S3=0;
unsigned long pre_time_S3=0;
unsigned long time_S3=0;


unsigned long interval_S4=0;
unsigned long pre_time_S4=0;
unsigned long time_S4=0;


unsigned long SettingTime_S1=0;
unsigned long PreSettingTime_S1=0;
unsigned long Total=0;


short FSR1Reading = 0;
short FSR2Reading = 0;
short FSR3Reading = 0;
short FSR4Reading = 0;

double y=0; 

void setup()
{
  Serial.begin(9600);
  
  pinMode(A0, INPUT);   
  pinMode(A1, INPUT);  
  pinMode(A2, INPUT);   
  pinMode(A3, INPUT); 
  pinMode(6, OUTPUT);   
  pinMode(7, OUTPUT); 
  pinMode(8, OUTPUT);   
  pinMode(9, OUTPUT); 
  //pinMode(31, OUTPUT); 
  
  //////////////////////////GSM
  Serial.println("SMS Messages Sender");
  boolean notConnected = true;
  while (notConnected)
  {
    if (gsmAccess.begin(PINNUMBER) == GSM_READY)
      notConnected = false;
    else
    {
      Serial.println("Not connected");
      delay(1000);
    }
  }

  Serial.println("GSM initialized");
  ///////////////////////////////////////////
 
}

void loop(){
  
Serial.print(analogRead(A0));
   delay(500);
   if (analogRead(A0) > 50) ////door is open
   {
      
   }
   
   
  
  
  
short FSR1Reading = analogRead(A0); 
short FSR2Reading = analogRead(A1);
short FSR3Reading = analogRead(A2);
short FSR4Reading = analogRead(A3);



 if  (FSR1Reading <50)  { delay(100); time_S1 = millis(); PreSettingTime_S1=SettingTime_S1; }
 else if (FSR1Reading > 50)  { pre_time_S1 =time_S1; Serial.print("FSR1Reading=");Serial.print(FSR1Reading); SettingTime_S1=millis(); 
                              Total = Total + ((((SettingTime_S1 - PreSettingTime_S1)/1000)));
                               y= 0.3851* pow(Total, 0.5836);
                          }
 
 
  if  (FSR2Reading <50)  { delay(100); time_S2 = millis();}
 else if(FSR2Reading > 50) { pre_time_S2 =time_S2; Serial.print("  FSR2Reading=");Serial.print(FSR2Reading);}
 
 
  if  (FSR3Reading <50)  { delay(100); time_S3 = millis();  }
  else if(FSR3Reading > 50) { pre_time_S3 =time_S3; Serial.print("  FSR3Reading=");Serial.print(FSR3Reading);}
 
 
  if  (FSR4Reading <50)  { delay(100); time_S4 = millis();}
 else if(FSR4Reading > 50){ pre_time_S4 =time_S4;Serial.print("  FSR4Reading=");Serial.println(FSR4Reading);}
 

   
   interval_S1 = abs (time_S1 - pre_time_S1); 
   Serial.print("Interval_S1=");  Serial.println(interval_S1);
   
   interval_S2 = abs (time_S2 - pre_time_S2); 
   Serial.print("Interval_S2=");  Serial.println(interval_S2);
   
   interval_S3 = abs (time_S3 - pre_time_S3); 
   Serial.print("Interval_S3=");  Serial.println(interval_S3);
   
   interval_S4 = abs (time_S4 - pre_time_S4); 
   Serial.print("Interval_S4=");  Serial.println(interval_S4);
   
   
   
   Serial.print("Total=");  Serial.println(y);
   
   if (interval_S1 > 20000) {  digitalWrite(6, HIGH);}
   else {digitalWrite(6, LOW); }
   
   if (interval_S2 > 20000) { digitalWrite(7, HIGH);}
   else {digitalWrite(7, LOW); }
   
   if (interval_S3 > 20000) { digitalWrite(8, HIGH);}
   else {digitalWrite(8, LOW); }
   
   if (interval_S4 > 20000) { digitalWrite(9, HIGH);}
   else {digitalWrite(9, LOW); }
   
   if (y>20 )
   {
     
     digitalWrite(6, LOW); digitalWrite(7, LOW); digitalWrite(8, LOW); digitalWrite(9, LOW); 
      /////////////sending SMS
     Serial.print("Inside GSM Loop"); 
     sms.beginSMS(remoteNum2);
     sms.print(txtMsg);
     sms.endSMS(); 
     y=0; 
     //delay(500);
     //////////////////////////
     //Send = 0;  
     //Serial.print(Send);
     //delay(2000);
     
   }
   
   
   //////23,25,27,29
////////////////// total setting 





}

This is the example code from the arduino gsm shield. You said this is working, so rather show us the code that is not working. Also what error do you get? Is your phone number correct? Did you enter the pin number correctly?