如何在电子邮件发送中加载plist电子邮件地址

时间:2014-11-28 04:31:28

标签: iphone xcode email plist

我设置了一个plist,plist有很多电子邮件地址,然后我想从plist加载电子邮件地址并发送电子邮件。

谢谢!

1 个答案:

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