使用此代碼。僅爲用戶輸入提供電子郵件地址。
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
NSString *msgTitle = @"Sample Title";
[picker setSubject:msgTitle];
NSArray *toRecipients =[[NSArray alloc] init];
NSArray *ccRecipients =[[NSArray alloc] init];
NSArray *bccRecipients =[[NSArray alloc] init];
[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];
[picker setBccRecipients:bccRecipients];
NSString *sum = @"The Email Body string is here";
NSString *emailBody;
emailBody = [NSString stringWithFormat:@"%@",sum];
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
-(void)launchMailAppOnDevice
{
NSString *recipients = @"mailto:?cc=,&[email protected]";
NSString *body = @"&body=";
NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}
祝你好運。
感謝您的回答。 我實現了代碼和它的工作順利......... – 2010-06-01 13:06:10
- (無效)launchMailAppOnDevice 需要它來修改 如果是,那麼請告訴我如何把所有的陣列中的這種方法 – 2010-06-02 06:46:10
@Arun夏爾馬。我認爲這種方法不需要。如果你想了解更多的細節,請參閱我更新的答案。它可能會幫助你。謝謝。 – Pugal 2010-06-02 09:18:56