A simply way to send email from Android and iOS using Xamarin is by using the Xamarin.Essentials.Email class. This allows us to use the default email client on the device to send our email, so we simply compose the email then pass the user to the default client to press the send button. What’s useful about this is our application can then leave the user to add any further information to the email without having to create the entry fields in our app.
You’ll need to add the NuGet package Xamarin.Essentials, then we can use the following code (don’t forget to add using Xamarin.Essentials)
try { var message = new EmailMessage { Subject = subject, Body = body, To = recipients, Cc = ccRecipients, Bcc = bccRecipients, BodyFormat = EmailBodyFormat.PlainText }; if (attachments != null && attachments.Count > 0) { attachments.ForEach(attachment => { message.Attachments.Add(new EmailAttachment(attachment)); }); } await Email.ComposeAsync(message); } catch (Exception ex) { // Log exception }
On Android this will display the default email client, for example gmail, with all the fields filled in along with any attachments.