According to this posting the 3.3v supply comes directly from the power supply on the Pi while the GPIO pins come from the BMC chip and can only supply a limited amount of current. That can explain why your solenoid energizes when connected to the 3.3v supply and not from the GPIO pin.
I suspect that you need to wire the solenoid as shown below (which is from here for an Arduino) except using the Pi GPIO pin instead of the Arduino Digital out. You might need to adjust the R1 resistor value to compensate for the Pi's 3.3v GPIO voltage instead of the Arduino's 5.0v.
This diagram shows using a transistor as a switch to have an external power supply energize the solenoid. The example I took this from used two 9v batteries in series as the external power supply.

Here's another example of using a transistor to switch on an external circuit from RPi GPIO Interface Circuits. The web page says that the 5v power supply shown can be any voltage up to 40v which the 2N3904 can support. The page says that this circuit is suitable for up to 100mA of current.
