2015-03-31 106 views

回答

3

我不認爲你可以改變From,因爲MFMailComposeViewController用於與iOS中的settings註冊電子郵件賬戶發送郵件,不您用於登錄您的應用的郵件地址。

+0

因此,是否有任何替代方法與MFMailComposeViewController類似,如果用戶沒有將您的電子郵件密碼提供給您的應用程序,我們可以根據我們的應用程序註冊電子郵件ID – 2015-04-01 06:12:39

+0

@SurajSS來更改「From」字段,代表他發送郵件 – CarmeloS 2015-04-01 06:15:37

+0

不,我有用戶的電子郵件ID和密碼已經登錄。其實我的應用程序是有不同的帳戶用戶添加有服務帳戶它可能是4-5任何帳戶。我只是想給選擇選擇1帳戶,並將其顯示到MFMailComposeViewController未提供的自定義「發件人」字段中 – 2015-04-01 06:20:12

-4

試試這個代碼

- (IBAction)openMail:(id)sender 
{ 
    if ([MFMailComposeViewController canSendMail]) 
{ 
    MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; 

    mailer.mailComposeDelegate = self; 

    [mailer setSubject:@"A Message from MobileTuts+"]; 

    NSArray *toRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
    [mailer setToRecipients:toRecipients]; 

    UIImage *myImage = [UIImage imageNamed:@"mobiletuts-logo.png"]; 
    NSData *imageData = UIImagePNGRepresentation(myImage); 
    [mailer addAttachmentData:imageData mimeType:@"image/png" fileName:@"mobiletutsImage"]; 

    NSString *emailBody = @"Have you seen the MobileTuts+ web site?"; 
    [mailer setMessageBody:emailBody isHTML:NO]; 

    [self presentModalViewController:mailer animated:YES]; 


} 
    else 
    { 
     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Failure" 
                 message:@"Your device doesn't support the composer sheet" 
                 delegate:nil 
               cancelButtonTitle:@"OK" 
               otherButtonTitles:nil]; 
     [alert show]; 

    } 

} 

的檢查結果

- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{ 
    switch (result) 
    { 
     case MFMailComposeResultCancelled: 
      NSLog(@"Mail cancelled: you cancelled the operation and no email message was queued."); 
      break; 
     case MFMailComposeResultSaved: 
      NSLog(@"Mail saved: you saved the email message in the drafts folder."); 
      break; 
     case MFMailComposeResultSent: 
      NSLog(@"Mail send: the email message is queued in the outbox. It is ready to send."); 
      break; 
     case MFMailComposeResultFailed: 
      NSLog(@"Mail failed: the email message was not saved or queued, possibly due to an error."); 
      break; 
     default: 
      NSLog(@"Mail not sent."); 
      break; 
    } 

     // Remove the mail view 
    [self dismissModalViewControllerAnimated:YES]; 
} 
+0

但如何更改郵件的「from」字段? – 2015-03-31 08:33:50

相關問題