Try making your MFMailComposeViewController a class variable.

On Sat, Jul 30, 2011 at 4:06 PM, Anita V. <[email protected]> wrote:

> Hi,
>
> I am trying to allow the user to send mail from within my app. Whenever I
> run this code, my app just removes the current view from its superview. I
> don't understand why!
>
> Here is the code I am using, within my view controller:
>
> public void MailButtonTouched()
>                {
>                        if(!MFMailComposeViewController.CanSendMail)
>                        {
>                                // display error
>                        }
>                        else
>                        {
>                                MFMailComposeViewController mail = new
> MFMailComposeViewController();
>                                mail.SetSubject("testing");
>                                mail.SetMessageBody("testing", true);
>                                mail.Finished += HandleMailFinished;
>
>                                this.PresentModalViewController(mail, true);
>                        }
>                }
>
>                void HandleMailFinished (object sender,
> MFComposeResultEventArgs e)
>                {
>                        if (e.Result == MFMailComposeResult.Sent) {
>                                UIAlertView alert = new UIAlertView ("Mail
> Alert", "Mail Sent",
>                                                                     null,
> "Yippie", null);
>                                alert.Show ();
>
>                                // handle other values
>                        }
>                        e.Controller.DismissModalViewControllerAnimated
> (true);
>                }
>
>
> Any help would be very much appreciated!
>
> Thanks,
> Anita
>
>
> --
> View this message in context:
> http://monotouch.2284126.n4.nabble.com/Trouble-sending-mail-from-within-my-app-tp3706782p3706782.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