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 = "";
ItemBody body = new ItemBody();
body.Content = "Hey!";
message.Body = body;
await mailClient.Me.Messages.AddMessageAsync(message);