/ Published in: Objective C
                    
                                        
Add MessageUI.framework reference
then in header file
#import
#import
#import
                then in header file
#import
#import
#import
                            
                                Expand |
                                Embed | Plain Text
                            
                        
                        Copy this code and paste it in your HTML
// Displays an email composition interface inside the application. Populates all the Mail fields.
MFMailComposeViewController *tempMailCompose = [[MFMailComposeViewController alloc] init];
tempMailCompose.mailComposeDelegate = self;
//[tempMailCompose setToRecipients:[NSArray arrayWithObject:@"[email protected]"]];
//[tempMailCompose setCcRecipients:[NSArray arrayWithObject:@"[email protected]"]];
[tempMailCompose setSubject:@"iPhone App recommendation"];
[tempMailCompose setMessageBody:body isHTML:NO];
[self presentModalViewController:tempMailCompose animated:YES];
[tempMailCompose release];
}
// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {
// Notifies users about errors associated with the interface
switch (result)
{
case MFMailComposeResultCancelled:
NSLog(@"Result: canceled");
break;
case MFMailComposeResultSaved:
NSLog(@"Result: saved");
break;
case MFMailComposeResultSent:
NSLog(@"Result: sent");
break;
case MFMailComposeResultFailed:
NSLog(@"Result: failed");
break;
default:
NSLog(@"Result: not sent");
break;
}
[self dismissModalViewControllerAnimated:YES];
}
// Launches the Mail application on the device. Workaround
NSString *recipients = [NSString stringWithFormat:@"mailto:%@?subject=%@", @"[email protected]", @"iPhone App recommendation"];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
}
// Call this method and pass parameters
-(void) showComposer:(id)sender{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil){
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail]){
[self displayComposerSheet:sender];
}else{
[self launchMailAppOnDevice:sender];
}
}else{
[self launchMailAppOnDevice:sender];
}
}
Comments
 Subscribe to comments
                    Subscribe to comments
                
                