Send an Email

PDF for offline use
Sample Code:
Related SDKs:

Let us know how you feel about this

Translation Quality


This recipe shows how to send an email using the MFMailComposeViewController.


To send an email using the MFMailComposeViewController follow these steps.

  1. Create a class variable for an MFMailComposeViewController.
MFMailComposeViewController mailController;
  1. Verify that the device is capable of sending mail - ensure you wrap all mail functionality inside the following CanSendMail check:
if (MFMailComposeViewController.CanSendMail) {
  // do mail operations here
  1. Instantiate an MFMailComposeViewController instance.
mailController = new MFMailComposeViewController ();
  1. Set the recipients, subject and message body.
mailController.SetToRecipients (new string[]{""});
mailController.SetSubject ("mail test");
mailController.SetMessageBody ("this is a test", false);
  1. Handle the Finished event.
mailController.Finished += ( object s, MFComposeResultEventArgs args) => {
  Console.WriteLine (args.Result.ToString ());
  args.Controller.DismissViewController (true, null);
  1. Present the MFMailComposeViewController.
this.PresentViewController (mailController, true, null);

Additional Information

The MFMailComposeViewController class has built-in support for sending emails. You can send emails to multiple recipients by including their addresses in the array passed into SetToRecipients. When the controller is dismissed, the result is available in the Finished event’s MFComposeResultEventArgs.Result, which is an MFMailComposeResult enumeration.

It is highly recommended that you test mail operations on real devices and not rely on results in the iOS Simulator

Xamarin Workbook

If it's not already installed, install the Xamarin Workbooks app first. The workbook file should download automatically, but if it doesn't, just click to start the workbook download manually.