If water has collected around or behind the frame, tilt the painting around in different directions to drain as much of the water off of it as possible. It generally is not necessary to remove the frame completely, and it is important not to remove the canvas from the stretcher bars it is attached to.
Don't be alarmed if you see white spots on the painting. These are caused by water trapped between the painting and its protective varnish, just like the rings that condensation from a glass sometimes leaves on a wooden table. Removing and replacing the varnish is a job for professional restorers. This process is a common task for restorers, and many famous paintings displayed in museums have undergone the procedure.
If there is mold growing on the painting, do not attempt to wipe or rub it off. Instead, spray both the front and back of the canvas with a disinfectant spray such as Lysol. Do not use bleach or any products that contain bleach. Cover the surface, but don't saturate it. Let the painting dry thoroughly. You will be able to tell that the mold is dead when it is dry and powdery. Take the painting outside and use a clean, dry brush to brush the dead mold spores off the surface of the painting. The spores can be hazardous to your health, so make sure you wear a face mask to avoid breathing them.
In many cases, it is possible for an original frame, even an ornate gilded frame, to be repaired or restored. Allow the frame to thoroughly dry out, but do not attempt to dry it too fast, or worse damage could occur. In the case of a gilded frame, water damage makes it particularly fragile, so handle it with extreme care.
If you have a major museum nearby, ask the staff for a recommendation for a professional who can assess the damage to your painting and restore or repair it. The museum may even offer the services of its own staff. A college or university art department is also a valuable resource. Libraries usually have conservationists who specialize in the care and repair of old books, and they might also be aware of resources available to you.