I have a .Net MAUI app. I have the following code to send emails (taken from https://learn.microsoft.com/en-us/dotnet/maui/platform-integration/communication/email?view=net-maui-7.0&tabs=windows):
try
{
if (Microsoft.Maui.ApplicationModel.Communication.Email.Default.IsComposeSupported)
{
var message = new EmailMessage
{
Subject = string.Empty,
Body = string.Empty,
BodyFormat = EmailBodyFormat.PlainText,
To = new List<string>() { _emailTechService },
};
await Email.Default.ComposeAsync(message);
}
else
{
await Shell.Current.DisplayAlert("Email Failure", $"Sending emails feature is not supported on this device", "OK");
}
}
catch (Exception ex)
{
App.HandleException(ex, true);
}
On iOS and Android it works correctly, but when I run it on Windows Machine in Visual Studio, IsComposeSupported is true, but Email.Default.ComposeAsync(message) throws a System.Runtime.InteropServices.COMException "The request is not supported."
How can I check if the feature is supported correctly to avoid the exception?