Book Image

iOS Development with Xamarin Cookbook

By : Dimitrios Tavlikos (USD)
Book Image

iOS Development with Xamarin Cookbook

By: Dimitrios Tavlikos (USD)

Overview of this book

Table of Contents (22 chapters)
iOS Development with Xamarin Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Using e-mail messaging in our application


In this recipe, we will learn how to use the e-mail messaging interface within an application.

Getting ready

Create a new Single View Application in Xamarin Studio and name it EmailMessageApp.

How to do it...

Perform the following steps:

  1. Add a button on the view of EmailMessageAppViewController and the MonoTouch.MessageUI namespace in the EmailMessageAppViewController.cs file.

  2. Enter the following code in the ViewDidLoad method:

    this.btnSendEmail.TouchUpInside += async (s, e) => {
      if (MFMailComposeViewController.CanSendMail)
      {
      this.mailController = new MFMailComposeViewController();
      this.mailController.SetToRecipients(new string[] { "[email protected]" });
      this.mailController.SetSubject("Email from Xamarin.iOS!");
      this.mailController.SetMessageBody("This is the message body!", false);
      this.mailController.Finished += this.MailController_Finished;
        await this.PresentViewControllerAsync(this.mailController, true);
      }  else
      {
        Console...