Example #1
0
        public static void SendMail(UIViewController parent, string to, string subject, MailAttachment attachment, string body, NSAction onDone)
        {
            if (MFMailComposeViewController.CanSendMail)
            {
                mailCompose = new MFMailComposeViewController();

                mailCompose.SetSubject(subject);
                mailCompose.SetToRecipients(new string[] { to });
                if (attachment != null)
                {
                    NSData att = NSData.FromFile(attachment.Filename);
                    mailCompose.AddAttachmentData(att, attachment.FileType, attachment.EmailFilename);
                }
                mailCompose.SetMessageBody(body, false);
                mailCompose.Finished += delegate(object sender, MFComposeResultEventArgs e) {
                    mailCompose.DismissModalViewControllerAnimated(true);
                    onDone();
                };
                parent.PresentModalViewController(mailCompose, true);
            }
        }
 public override void Finished(MFMailComposeViewController controller, MFMailComposeResult result, NSError error)
 {
     controller.DismissModalViewControllerAnimated(true);
 }