你好,歡迎來到IOS教程網

 Ios教程網 >> IOS編程開發 >> IOS開發綜合 >> ios發送郵件

ios發送郵件

編輯:IOS開發綜合

ios發送郵件

by 伍雪穎


第一種:

NSString *myEmail = @"[email protected]";
NSString *toemail = @"[email protected]";
NSString *emailDetail = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=Feedback!&body=Dear:",toemail,myEmail];
[[UIApplication sharedApplication] openURL: [NSURL URLWithString: emailDetail]];

第二種:

- (void)displayMailPicker {
    MFMailComposeViewController *mailPicker = [[MFMailComposeViewController alloc] init];
    mailPicker.mailComposeDelegate = self;
    [mailPicker setSubject: @"Feedback!"];
    NSArray *toRecipients = [NSArray arrayWithObject: @"[email protected]"];
    [mailPicker setToRecipients: toRecipients];
    NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", nil];
    [mailPicker setCcRecipients:ccRecipients];
    
    // add a picture
    UIImage *addPic = [UIImage imageNamed: @"[email protected]"];
    NSData *imageData = UIImagePNGRepresentation(addPic);
    [mailPicker addAttachmentData: imageData mimeType: @"" fileName: @"Icon.png"];
    
    NSString *emailBody = @"Dear:";
    [mailPicker setMessageBody:emailBody isHTML:YES];
    [self presentViewController:mailPicker animated:YES completion:nil];
}

- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error {
    [self dismissViewControllerAnimated:YES completion:nil];
}

一般用第二種

  1. 上一頁:
  2. 下一頁:
蘋果刷機越獄教程| IOS教程問題解答| IOS技巧綜合| IOS7技巧| IOS8教程
Copyright © Ios教程網 All Rights Reserved