-1

我想放一些类似订购相同数据包的东西,如果我完成了我的订单,我想发送电子邮件;如何修改此代码以更改电子邮件的正文?

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:@"123@abc.com", 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];

    }

} 
4

2 回答 2

5

消息正文设置在这一行:

       

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

因此,只需将“此处的消息”更改为您希望电子邮件说的任何内容。你也可以让它成为你在别处设置的 NSString 对象。

于 2012-05-10T23:38:12.500 回答
1

您可以修复此代码。您的消息正文设置在此行:

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

希望这可以帮助。

于 2014-04-07T22:00:37.893 回答