Thursday, April 4, 2024

Open default email app in .NET MAUI

Sample Code:

 if (Email.Default.IsComposeSupported)

{

    string subject = "Hello!";

    string body = "Excellent!";

    string[] recipients = new[] { "Support@3MbSolutions.com", "Marketing@3MbSolutions.com" };


    var message = new EmailMessage

    {

        Subject = subject,

        Body = body,

        BodyFormat = EmailBodyFormat.PlainText,

        To = new List<string>(recipients)

    };


    await Email.Default.ComposeAsync(message);

}

If your project's Target Android version is set to Android 11 (R API 30) or higher, you must update your Android Manifest with queries that use Android's  package visibility requirements.

In the Platforms/Android/AndroidManifest.xml file, add the following queries/intent nodes in the manifest node:

<queries>

  <intent>

    <action android:name="android.intent.action.SENDTO" />

    <data android:scheme="mailto" />

  </intent>

</queries>


No comments:

Post a Comment

How to add Apple Developer Account to Visual Studio

  Generating an API Key Before you can add an Apple Developer Account to Visual Studio, you'll need to generate an API Key. Generating a...