Not so. The UV spectrum emitted from most sunlamps darkens skin primarily due to oxidation and redistribution of pre-existing melanin (the pigment in skin that absorbs UV); it has a minimal effect on the amount of melanin. The resulting tan is thus mostly cosmetic, not protective.
In an investigation by the U.S. House Energy & Commerce Committee in 2012, four out of five tanning salons made such false claims when contacted by people pretending to be fair-skinned teenage girls. Nearly all the salons denied the known health risks, with half denying that tanning increases skin cancer risk, calling that a “big myth,” “rumor” or “hype.”
Though vitamin D has been linked in many observational studies with reduced risk for some cancers (such as prostate, breast and colon), results have been inconsistent and don’t prove cause and effect. In any case, even if vitamin D has anti-cancer benefits, there are no studies indicating that it has to come from sunlight or sunlamps.
It’s true that bright (visible) light can have therapeutic effects on this mood disorder, but there’s no definitive evidence that UV (invisible) rays have the same benefit. In fact, special lamps designed to treat seasonal affective disorder (SAD) filter out most UV.