Sunlight alone don't help, it helps just because our body makes Vitamin D during the sunbathing process.
So sunbathing is one of many way of integrating Vitamin D in our body not THE way.