Many times we require to get the logged in user in sharepoint.
We can easily get the SPUser object of the current logged in user:
This will give the current logged in user. Now you can get user's email, groupName, Name from various properties like:
user.LoginName, user.Email etc