Sending a test text message when button is pressed

So I just bought a UNO and a GPRS/GSM shield, and I’m trying to figure out how to code the arduino so that when I press a button, a text message is sent to a specific number. Arduino is all new to me, and here is the code I have so far based on a bit of researching:

#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial mySerial(7,8);

//button pin
int buttonPin = 3;

void setup()
{
  mySerial.begin(19200);    // the GPRS baud rate   
  Serial.begin(19200);    // the GPRS baud rate 
  delay(500);
}

void loop(){
//If button is pressed, send text message 
int buttonVal = digitalRead(buttonPin);
if(buttonVal == HIGH){
SendTextMessage();
delay(500);
}

//Send text message
void SendTextMessage()
{
  mySerial.print("AT+CMGF=1\r");    //Because we want to send the SMS in text mode
  delay(100);
  mySerial.println("AT+CMGS=\"+44##########\""); //send sms message, insert your own phone number including the country code
  delay(100);
  mySerial.print("Test message from Arduino");//the content of the message
  delay(100);
  mySerial.print((char)26);//the ASCII code of the ctrl+z is 26
  delay(100);
  mySerial.println();
}

I have replaced my number with hashes obviously, but should this code work?
Thanks

should this code work?

Depends on how the switch is wired, for one thing. You seem to have forgotten to describe that.

pulldown resistor between pin 3 and GND, then a spst button between 5v and pin 3.

So, what does the code actually do? The GSM chip returns a response to every AT command. It seems a shame not to read what the chip replies with. Might provide a clue.

You've forgotten to declare your button pinMode.

You need to add pinMode(buttonPin, INPUT);

Thanks uobstudent, I'll add that in now.

PaulS, thanks, how can I read what the GSM chip is replying? It's a SIM900 chip.

The code is supposed to connect to the network and wait for the button press, where it then sends the text. Afterwards it will stay connected and wait for the button to be pressed again

I changed the code; I copied the code from this instructable:http://www.instructables.com/id/Mailbox-Phone-Alert/?ALLSTEPS and deleted the parts that refer to the light sensor and rearranged it so that a text is sent at the press of a button. It does not work still.

This is how everything is connected, my GSM shield is very similar to this one: https://ermagherd.files.wordpress.com/2013/04/img_20130407_120640.jpg

#include <SoftwareSerial.h>
#include <String.h>

SoftwareSerial mySerial(7,8);

//button pin
int buttonPin = 3;

void setup()
{
  mySerial.begin(19200);    // the GPRS baud rate   
  Serial.begin(19200);    // the GPRS baud rate 
  delay(500);
}

void loop(){
int buttonVal = digitalRead(buttonPin);
if(buttonVal == HIGH)
SendTextMessage();
delay(500);
}

//Send a text message
void SendTextMessage()
{
  mySerial.print("AT+CMGF=1\r");    //Because we want to send the SMS in text mode
  delay(100);
  mySerial.println("AT+CMGS=\"+############\""); //send sms message, insert your own phone number including the country code
  delay(100);
  mySerial.print("You've got mail!");//the content of the message
  delay(100);
  mySerial.print((char)26);//the ASCII code of the ctrl+z is 26
  delay(100);
  mySerial.println();
}
void loop(){
int buttonVal = digitalRead(buttonPin);
if(buttonVal == HIGH)
SendTextMessage();
delay(500);
}

Would you forget the damned switch until you KNOW that the GSM shield works?

Leave loop() empty. Call SendTextMessage() from setup() UNCONDITIONALLY!.

Are you using the Arduino GSM/GPRS shield or a different one? If a different one could you provide a link to the shield you are using?