2011-08-19 12 views
6

मेरे आईपैड एप्लिकेशन के भीतर से मैं कस्टम बॉडी टेक्स्ट के साथ आईपैड के ई-मेल ऐप का आह्वान करना चाहता हूं। प्रेषक और विषय खाली हो जाएगा, एकमात्र पैरामीटर जिसे मैं सेट करना चाहता हूं वह ई-मेल संदेश का पाठ है। ऐसा कैसे किया जा सकता था?आईओएस एसडीके: ई-मेल आवेदन कैसे शुरू करें?

धन्यवाद!

उत्तर

5

ऐप्पल के दस्तावेज़ में MFMailComposeViewController पर एक नज़र डालें। आप इसे इस तरह का उपयोग कर सकते हैं:

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

अपने .h फ़ाइल में #import <MessageUI/MessageUI.h> जोड़ने के लिए मत भूलना। यह आपके प्रतिनिधि को विधियों को कॉल करने के बारे में बताएगा जब यह रद्द कर दिया गया था या ईमेल भेजा गया था (सफलतापूर्वक या नहीं)। मुझे बताना अगर ये आप के लिए काम करता है।

9

क्यों न केवल अपने ऐप के अंदर एक ईमेल संदेश संगीतकार खोलें?

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]]; 

या, जैसा कि Mihai सुझाव दिया है, जो आप अपने अनुप्रयोग से बाहर निकले बिना मेल भेजने के लिए अनुमति देता है MFMailComposeViewController पर एक नज़र डालें।

3

उपयोगकर्ता को मेल भेजने के लिए निम्नलिखित विधि का उपयोग किया जाता है।

-(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]; 
संबंधित मुद्दे