Send email using Mail API in C#

Note: This post may or may not be outdated, as it uses the SDK from when the Office 365 APIs were in Preview.

Because I couldn't find anything online, here's my contribution to the community. This code snippet shows you how to send a message using the C# SDK for the Exchange Mail REST API.

IMessage message = new Message();
Recipient recipient = new Recipient();
recipient.Name = "abcde";
recipient.Address = "abcde@12345.onmicrosoft.com";
ItemBody body = new ItemBody();
body.Content = "Hey!";
message.Body = body;
message.ToRecipients.Add(recipient);
await mailClient.Me.Messages.AddMessageAsync(message);