我设置了一个plist,plist有很多电子邮件地址,然后我想从plist加载电子邮件地址并发送电子邮件。
谢谢!
答案 0 :(得分:0)
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *docPath = [documentsDirectory stringByAppendingPathComponent:@"filename.plist"];
NSArray *emailNames = [NSArray arrayWithContentsOfFile:docPath];
发送电子邮件:
NSString *emailTitle = @"Email Title";
NSString *messageBody = @"This is where the body goes";
NSArray *toRecipents = [NSArray arrayWithArray:emailNames];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];