Google is your friend: Be nice and visit him often. He can answer questions a lot more quickly than posting them here...
A very quick search using part of your question as the search term gave over 3 million hits:
Google "Signin into Microsoft account Programmatically"[
^]
The top link is MSDN explaining how to do it...
In future, please try to do at least basic research yourself, and not waste your time or ours.