You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
Seekers/Helpers/EmailHelper.cs

33 lines
941 B

using Microsoft.Maui.ApplicationModel.Communication;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
namespace Justice.Helpers
{
public static class EmailHelper
{
public static async Task SendEmailAsync(string subject, string body, string recipient)
{
try
{
var message = new EmailMessage
{
Subject = subject,
Body = body,
To = new List<string> { recipient }
};
await Email.ComposeAsync(message);
}
catch (FeatureNotSupportedException)
{
throw new Exception("Email is not supported on this device or platform.");
}
catch (Exception ex)
{
throw new Exception($"Unable to send email: {ex.Message}");
}
}
}
}