0

I am working in Xamarin ios. I need to implement mail functionality. I implemented the code and getting "Sent" in result. But it is not received by recipients. I am using MFMailComposeViewController to implement the mail functionality.

following is the code:

      if (MFMailComposeViewController.CanSendMail)
        {
            mailController = new MFMailComposeViewController();
            mailController.SetToRecipients(new string[] { [email protected] });
            mailController.SetSubject("");
            mailController.SetMessageBody("", false);
            mailController.Finished += (object s, MFComposeResultEventArgs args) =>
            {
                                   args.Controller.DismissViewController(true, null);
            };

        }
anand
  • 1,399
  • 5
  • 23
  • 55

1 Answers1

0
if (MFMailComposeViewController.CanSendMail)
    {
        mailController = new MFMailComposeViewController();
        mailController.SetToRecipients(new string[] { [email protected] });
        mailController.SetSubject("");
        mailController.SetMessageBody("", false);

        mailController.Finished += (object s, MFComposeResultEventArgs args) =>
        {
                               args.Controller.DismissViewController(true, null);
        };
        this.ShowViewController(mailController, this);

    }

Mail Controller needs to be displayed on top of current controller. So Add the last line and try running the code.

It should open up a Email Window on top of your app. Where you can see all the details already filled up.

iOS doesnt allow you to send emails without opening up a email Client. So its on your user to either send the email or not.

soan saini
  • 230
  • 3
  • 9