A solenoid converts an electrical current directly into linear a mechanical motion. It is therefore related to a relay. Wire wound as a coil acts as an electromagnet when current is passed through it. Inside the coil body there is a so called plunger, performing the mechanical action. Activated by the electrical current. The plunger can move freely though the inside of the coil. Activating the coil will pull the plunger inside the coil. As the magnetic field is the strongest in the center of a coil. Some solenoids have mechanical springs to support the plunger when moving outside the coil when the current is switched off. Others have permanent magnets to latch (hold) the plunger fixed in a state. The current through the coil needs to be reversed to get an opposing magnetic field to release the plunger.
Applications
Door holding magnets. Ding Dong door bell. Valves.