Hi Chris,

what works for me is the following two bits of code


                                                pdfFileName = Path.Combine 
(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "docs.pdf");
                                                NSData data = NSData.FromFile 
(pdfFileName);
                                                MFMailComposeViewController 
mail = new MFMailComposeViewController ();
                                                mail.SetSubject ("docs");
                                                mail.SetMessageBody ("", true);
                                                mail.Finished += 
HandleMailFinished;
                                                mail.AddAttachmentData (data, 
"text/x-pdf", "docs.pdf");
                                                
this.NavigationController.PresentModalViewController (mail, true);



                void HandleMailFinished (object sender, 
MFComposeResultEventArgs e)
                {
                        if (e.Result == MFMailComposeResult.Sent) {
                                UIAlertView alert = new UIAlertView 
("sdklsdksdlkskdsd", "Mail Sent", null, "Ok", null);
                                alert.Show ();
                        }  else if (e.Result == MFMailComposeResult.Cancelled) {
                        }  else if (e.Result == MFMailComposeResult.Saved) {
                        }
                        e.Controller.DismissModalViewControllerAnimated (true);
                }

you can bung some code in the cancelled result if you need to.

ATB

Alex


On 26 Sep 2012, at 21:28, Chris_M <[email protected]> wrote:

> 
> My app has a UITabBarController. One of the tabs is to enable a user to send
> an email to my clients. I created a UIViewController for that tab bar item,
> and in its ViewDidLoad I have code that uses Reachability to determine if an
> internet connection is there, and if
> MFMailComposeViewController.CanSendMail, I invoke a MailComposeDelegate so
> the user can compose and send an email. This all works just fine. But I have
> two problems.
> 
> First, if I cancel the email composition, and the compose email modal view
> goes away, the view is blank, and navigating away from this screen and back
> to it doesn't "reset" anything (not that I expected it to). So I need to
> figure out how to "rest" that mail functionality in the
> MFMailComposeResult.Cancelled block of code (right now it just disposes of
> the modal view controller in an animated fashion).
> 
> Second, when I do send an email, I get a "Mail Alert: Mail Sent" alert as
> expected, but it stays on the screen and effectively locks the app until I
> force close it and launch it again. So obviously I'm missing a step in there
> somewhere. Presumably something I need to add to the
> MFMailComposeResult.Sent block of code. Maybe I need to set how many seconds
> the "Mail Sent" alert stays on the screen, or something like that? 
> 
> I couldn't find code examples online to help with this, but maybe I'm not
> looking for the right things. Anyway, any suggestions? 
> 
> 
> --Chris
> 
> 
> 
> 
> 
> 
> --
> View this message in context: 
> http://monotouch.2284126.n4.nabble.com/Fun-with-MFMailComposeViewController-tp4657247.html
> Sent from the MonoTouch mailing list archive at Nabble.com.
> _______________________________________________
> MonoTouch mailing list
> [email protected]
> http://lists.ximian.com/mailman/listinfo/monotouch

_______________________________________________
MonoTouch mailing list
[email protected]
http://lists.ximian.com/mailman/listinfo/monotouch

Reply via email to