The three basic items to make an electromagnet are a source of current, conducting wire, and a metallic core. Electromagnetic is a type of magnet which is formed with the help of electricity.
When the current is allowed to pass through the wire and the metallic core, the magnetic field is generated around the metallic core and when the current is turned off, the metallic core losses the property of magnetism.
The sun is 1AU away from Earth, meaning that it is 92,955,807 miles away from Earth. Even if you travelled your whole life, the chances of you reaching the sun are astronomically low