2

I found two articles (Open default mail client along with a attachment and open an existing email with outlook from a website) which indicate using the "mailto" token allows passing the "subject" and "body" as parameters in the URL. So far, this hasn't worked for me. (NOTE: I'm trying to get this to work on the Android emulator and the email account is configured and working.)

I'm doing:

await Launcher.OpenAsync($"mailto:{address}?subject:{subject}&body:{body}");

After having populated appropriate variables. It does open the Gmail app and opens a draft with the address in the "to". But the "subject" and "body" are empty.

Ken White
  • 123,280
  • 14
  • 225
  • 444
AdvApp
  • 1,094
  • 1
  • 14
  • 27

1 Answers1

1

In MAUI, you can use the Email.ComposeAsync method:

var message = new EmailMessage
    {
        Subject = subject,
        Body = body,
        BodyFormat = EmailBodyFormat.PlainText,
        To = new List<string>(recipients)
    };

    await Email.Default.ComposeAsync(message);

Note that you need to add the "mailto" scheme to Android and iOS manifests. Please refer to Email for additional information.

Alex Russkov
  • 323
  • 2
  • 8
  • 1
    Yes, the 'ComposeAsync()' threw the exception: "Microsoft.Maui.Essentials--Specified method is not supported" until I added the "package visibility requirement" for SENDTO. – AdvApp Mar 18 '23 at 15:28