English Translation
Mary felt happy when she learned the results of the election.
Unnatural word-for-word translation. We don’t usually bridge two clauses with the conjunction ~とき in this context because there is a clear cause-effect relationship between her happiness (the former clause) and the notification (the latter clause). In other words, use ~とき where two clauses happen at the same time but there is no connection (e.g. A bomb was exploded when I was eating at home).
Also, 嬉しく思った is very wordy. We don’t say it.
My alternative translation is:
メアリーは選挙結果を知って、喜んだ。(メアリーはせんきょけっかをしって、よろこんだ)
The particle て means “and then”. So, the result of the election is the trigger of her happiness. That’s the function of て.
You can replace 選挙結果 with 選挙の結果 (inserting の), or with 選挙速報 (せんきょそくほう; don’t use の). Major media outlets usually report the win/lose results as a breaking news before finishing counting all votes. 選挙速報 is a breaking news for elections. And candidates usually give a public speech right after 選挙速報.
メアリーは当選確実の知らせを受けて喜んだ。(とうせんかくじつのしらせ)
This is another free translation. 当選 means “winning an election” and 確実 is “being assured/confirmed”. TV programs of 選挙速報 frequently use the term 当選確実 as a screen caption along with the winner’s face photo.
知らせを受ける suggests that Mary is the winner: either she is the runner or she is the campaign manager. If Mary is just an ordinary supporter of the candidate, replace 知らせを受けて with 当選確実と知って.