2012-05-10 62 views
-1

我想把類似的東西放在同一個數據包,如果我完成我的訂單,我想發送電子郵件;我怎樣才能修改這段代碼來改變電子郵件的正文?如何更改MFMailComposeViewController中的電子郵件正文?

inappemailViewController.h

#import <UIKit/UIKit.h> 
#import <MessageUI/MFMailComposeViewController.h> 

@interface inappemailViewController : 
UIViewController <MFMailComposeViewControllerDelegate> { 
} 

-(IBAction)email; 
@end 

inappemailViewController.m

-(IBAction)email { 

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

    [composer setMailComposeDelegate:self]; 

    if ([MFMailComposeViewController canSendMail]) { 

     [composer setToRecipients:[NSArray arrayWithObjects:@"[email protected]", nil]]; 

     [composer setSubject:@"subject here"]; 

     [composer setMessageBody:@"message here" isHTML:NO]; 

     [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 

     [self presentModalViewController:composer animated:YES]; 

     [composer release]; 

    } 

    else 

     [composer release]; 

} 

-(void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error { 

    if (error) { 

     UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"error" 

message:[NSString stringWithFormat:@"error %@", [error description]] 

delegate:nil cancelButtonTitle:@"dismiss" otherButtonTitles:nil, nil]; 

     [alert show]; 

     [alert release]; 

     [self dismissModalViewControllerAnimated:YES]; 

    } 

    else { 

     [self dismissModalViewControllerAnimated:YES]; 

    } 

} 

回答

5

消息體被設置在這條線:

[composer setMessageBody:@"message here" isHTML:NO]; 

所以強制不要在這裏改變「信息」,無論你想要電子郵件說什麼。你也可以使它成爲你在別處設置的NSString對象。

1

您可以修復此代碼。您的消息體設置在這條線:

[composer setMessageBody:@"message here" isHTML:NO]; 

希望這有助於。

相關問題