2011-08-19 14 views

cevap

5

Apple'ın belgelerinde MFMailComposeViewController'a bir göz atın. Bu gibi kullanabilirsiniz:

MFMailComposeViewController *controller=[[MFMailComposeViewController alloc]init]; 
controller.delegate = self; 
[controller setMessageBody:<#yourBody#> isHTML:<#isHTML#>]; 
[self presentModalViewController:controller animated:YES]; 
[controller release]; 

sizin .h dosyada #import <MessageUI/MessageUI.h> eklemeyi unutmayın. Temsilcinizde, iptal edildiğinde veya e-posta gönderildiğinde (başarılı ya da değil) sizi bilgilendirmek için yöntemleri çağırır. senin işine yarar mı bileyim.

9

Uygulamanızın içinde neden bir e-posta iletisini açmıyorsunuz?

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; 

[mailController setSubject:@"my subject"];     
[mailController setMessageBody:@"my message" isHTML:NO]; 

mailController.mailComposeDelegate = self; 

UINavigationController *myNavController = [myViewController navigationController]; 

if (mailController != nil) { 
    if ([MFMailComposeViewController canSendMail]){ 
     [myNavController presentModalViewController:mailController animated:YES]; 
    } 
} 

[mailController release]; 
5
NSString *body = @"Hello Mail"; 
NSString *mailtoURLString = [NSString stringWithFormat:@"mailto:?body=%@", [body stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]]; 
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:mailtoURLString]]; 

Veya, Mihai önerildiği gibi, uygulamanızı bırakmadan posta göndermek için izin verir MFMailComposeViewController bakabilirsiniz.

3

Aşağıdaki yöntem, kullanıcıya posta göndermek için kullanılır.

-(void)sendMail:(UIImage *)image 
{ 
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

    // Set the subject of email 
    [picker setSubject:@"Picture from my iPhone!"]; 

    // Add email addresses 
    // Notice three sections: "to" "cc" and "bcc" 
    [picker setToRecipients:[NSArray arrayWithObjects:@TO mailID1",@TO mailID2", nil]]; 
    [picker setCcRecipients:[NSArray arrayWithObject:@"CC MailID"]]; 
    [picker setBccRecipients:[NSArray arrayWithObject:@"BCC Mail ID"]]; 

    // Fill out the email body text 
    NSString *emailBody = @"I just took this picture, check it out."; 

    // This is not an HTML formatted email 
    [picker setMessageBody:emailBody isHTML:NO]; 

    // Create NSData object as PNG image data from camera image 
    NSData *data = UIImagePNGRepresentation(image); 

    // Attach image data to the email 
    // 'CameraImage.png' is the file name that will be attached to the email 
    [picker addAttachmentData:data mimeType:@"image/png" fileName:@"CameraImage"]; 

    // Show email view 
    [self presentModalViewController:picker animated:YES]; 

    // Release picker 
    [picker release]; 
} 
0
NSString *textToShare = @"http:yourmail.com/"; 

NSArray *objectsToShare = @[textToShare]; 

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:objectsToShare applicationActivities:nil]; 

NSArray *excludeActivities = @[UIActivityTypeAirDrop,UIActivityTypeSaveToCameraRoll]; 

activityVC.excludedActivityTypes = excludeActivities; 
[activityVC setValue:@"yourmail" forKey:@"subject"]; 

[self presentViewController:activityVC animated:YES completion:nil];