Mail Composer Address Problem

前端 未结 2 595
谎友^
谎友^ 2020-12-22 12:49

I found email composer sample code from iphone OS Ref Library. Here is a code-

Code:

NSArray *toRecipients = [NSArray arrayWithObject:@\"first@exampl         


        
相关标签:
2条回答
  • 2020-12-22 13:05
    MFMailComposeViewController* controller = [[MFMailComposeViewController alloc] init];
        controller.mailComposeDelegate = self;
        [controller setToRecipients:arr];
        [controller setCcRecipients:arr2];
        [controller setBccRecipients:arr3];
        [controller setMessageBody:@"Hello there." isHTML:NO]; 
    
    0 讨论(0)
  • 2020-12-22 13:08

    Use this code. To Give a Email address as user input only.

    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=,&subject=@";
    
         NSString *body = @"&body=";
    
         NSString *email = [NSString stringWithFormat:@"%@%@", recipients, body];
    
        email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
    
        [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
    
      }
    

    Best of luck.

    0 讨论(0)
提交回复
热议问题