2010-06-01 3 views
0

아이폰 OS 참조 라이브러리에서 이메일 작성기 샘플 코드를 발견했습니다.메일 작성자 주소 문제

NSArray *toRecipients = [NSArray arrayWithObject:@"[email protected]"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"[email protected]", @"[email protected]", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"[email protected]"]; 

내 질문은 사용자의 입력을하는 방법입니다 : 여기에 코드 -

코드는? 여기에 모든 전자 메일 주소가 코드로 미리 정의되어 있습니다. 그렇다면 to, CC, Bcc, Subject 및 Body 필드의 ID는 무엇입니까?

답변

1

이 코드를 사용하십시오. 전자 메일 주소를 사용자 입력으로 제공하는 것.

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]]; 

    } 

행운을 빈다.

+0

답변 해 주셔서 감사합니다. 그 코드와 그 작업을 성공적으로 구현했습니다 ......... –

+0

- (void) launchMailAppOnDevice 예라면 을 수정해야합니다. 그러면이 배열에 모든 배열을 넣는 방법을 알려주세요. –

+0

@Arun Sharma . 나는 그 방법이 필요하지 않다고 생각한다. u에 대한 자세한 내용은 내 업데이트 된 답변을 참조하십시오. 그것은 당신을 도울 수 있습니다. 감사. – Pugal

1
MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init]; 
    controller.mailComposeDelegate = self; 
    [controller setToRecipients:arr]; 
    [controller setCcRecipients:arr2]; 
    [controller setBccRecipients:arr3]; 
    [controller setMessageBody:@"Hello there." isHTML:NO];