A hacking group associated with the Iranian government attempted to infiltrate the email accounts of staff members involved in U.S. presidential campaigns as part of a broader effort to gather intelligence before the U.S. election, Microsoft Corp. announced on Friday.