Sending sms to a number stored in variable

Can anyone help me with this? I am using Gsm with arduino and want to send a message to a number I save in a variable. But my AT command does not work.
Here is the relevant portion of code:

String number1 = "03360234233";
Serial1.print("AT+CMGS=\"" + number1 + "\"");

Did you try Serial1.write instead?

Using this and printing to the serial monitor:-

String number1 = "03360234233";
Serial.print("AT+CMGS=\"" + number1 + "\"");

yields this result:-AT+CMGS="03360234233"Is that what it's supposed to look like?
(I've never used a GSM shield.)

Edit: Serial1.write("AT+CMGS=\"" + number1 + "\"");results in:-no matching function for call to 'HardwareSerial::write(StringSumHelper&)'

CrossRoads:
Did you try Serial1.write instead?

It gives error.

OldSteve:
Using this and printing to the serial monitor:-

String number1 = "03360234233";

Serial.print("AT+CMGS="" + number1 + """);



yields this result:-


AT+CMGS="03360234233"

Yes. When I insert the number instead of variable, message is sent. But with variable, there's no error and nothing is sent.

Which microcontroller are you using?
Serial1 will work on 1284 and 2560.
For Uno, only Serial is available. To talk to a SMS device you then need one of the software serial libraries and have to define a SerialSMS name or similar to use.

I am using arduino mega 2560.

Have you tried:-

char number1[12] = "03360234233";
Serial1.print("AT+CMGS=\"");
Serial1.print(number1);
Serial1.print("\"");

or

char number1[12] = "03360234233";
char outString[22];
sprintf_P(outString, PSTR("AT+CMGS=\"%s\""), number1);
Serial1.print(outString);

I've never used, and don't trust, the 'String' class.

I tried it with char array. It doesn't work too.

There should be no difference between this:-

char number1[12] = "03360234233";
char outString[22];
sprintf_P(outString, PSTR("AT+CMGS=\"%s\""), number1);
Serial1.print(outString);

and this:-Serial1.print("AT+CMGS=\"03360234233\"");  // You said this works.
Both should produce exactly the same result.