-2

我正在从 iphone 应用程序发送电子邮件,它工作正常我想在电子邮件中添加 cc 任何想法如何做到这一点。我正在使用以下代码,请你帮助如何在其中添加 CC。

谢谢。

初始化控制器以发送电子邮件

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;


    NSString*giveFileName=@"CPAC_Contract_Equine";  
NSString *fileName;
//fileName = [[NSString alloc]initWithFormat:@"%@.pdf",giveFileName];
fileName = [[NSString alloc]initWithFormat:@"%@",giveFileName];


NSString*myFileName=@"W9.pdf";


NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];


NSString *pdfFileName = [documentsDirectory stringByAppendingPathComponent:fileName];


NSMutableData *myPdfData = [NSMutableData dataWithContentsOfFile:pdfFileName];



NSString *pathJam = [[NSBundle mainBundle] pathForResource:@"W9" ofType:@"pdf"]; 
NSData *myDataJam = [NSData dataWithContentsOfFile: pathJam]; 

NSArray * toRecipients = [NSArray arrayWithObject:@""];


[picker setToRecipients:toRecipients];








[picker setSubject:@"CPAC Contract for Equine-Sam Veterinarian"];

[picker addAttachmentData:myPdfData mimeType:@"application/pdf" fileName:giveFileName];




NSString * emailBody =@"<html><body>Thank you for your participation in Consulting<br>Practitioner and Client Program.</br><br>Attached is the copy of your signed contract for your records<p>Please email or fax your completed W-9 form to<br>our PEI Support Team<br>Email:PEISupportServices@zoetis.com<br>Fax:800-741-1310<body></html>";



[picker setMessageBody:emailBody isHTML:YES];





[self.navigationController presentViewController:picker animated:YES completion:nil];
4

3 回答 3

0
    NSString *subject = @"";
    NSString *body = @"";
    NSString *address = @"to@gmail.com";
    NSString *cc = @"cc@gmail.com";
    NSString *path = [NSString stringWithFormat:@"mailto:%@?cc=%@&subject=%@&body=%@", address, cc, subject, body];
    NSURL *url = [NSURL URLWithString:[path stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
    [[UIApplication sharedApplication] openURL:url];
于 2013-05-27T08:50:34.730 回答
0

MFMailComposeViewController 有一个setCcRecipients:方法。你会像这样使用它:

[picker setCcRecipients:[NSArray arrayWithObject:@"someone@example.com"]];
于 2013-05-25T09:52:04.370 回答
0
[mailComposeViewController setToRecipients:@[@"ibanking@com"]];

[mailComposeViewController setCcRecipients:@[@"ccs.cmc@com"]];
于 2019-04-07T04:14:00.147 回答