Пример #1
0
 @SuppressWarnings({"unchecked", "rawtypes"})
 private void sendMail() {
   MFMailComposeViewController picker = new MFMailComposeViewController();
   picker.setMailComposeDelegate(
       new MFMailComposeViewControllerDelegate.Adapter() {
         @Override
         public void mailComposeControllerDidFinish(
             MFMailComposeViewController controller, MFMailComposeResult result, NSError error) {
           controller.dismissViewController(true, null);
         }
       });
   NSArray usersTo = new NSArray(new NSString("*****@*****.**"));
   picker.setToRecipients(usersTo);
   picker.setSubject("Test Mail");
   window.getRootViewController().presentViewController(picker, true, null);
 }
  private void presentMailComposeViewController(String recipient) {
    // Create the compose email view controller
    MFMailComposeViewController composeEmailViewController = new MFMailComposeViewController();

    // Set the recipient to the selected email and a default text
    composeEmailViewController.setMailComposeDelegate(mailComposeDelegate);
    composeEmailViewController.setSubject("Join me on Anypic");
    composeEmailViewController.setToRecipients(Arrays.asList(recipient));
    composeEmailViewController.setMessageBody(
        "<h2>Share your pictures, share your story.</h2><p><a href=\"http://anypic.org\">Anypic</a> is the easiest way to share photos with your friends. Get the app and share your fun photos with the world.</p><p><a href=\"http://anypic.org\">Anypic</a> is fully powered by <a href=\"http://parse.com\">Parse</a>.</p>",
        true);

    // Dismiss the current modal view controller and display the compose
    // email one.
    // Note that we do not animate them. Doing so would require us to
    // present the compose
    // mail one only *after* the address book is dismissed.
    dismissViewController(false, null);
    presentViewController(composeEmailViewController, false, null);
  }