发送带有以下收据的电子邮件至:personA cc: personB bcc :personC
这三个人都会收到电子邮件。并且所有收到的电子邮件都会在收据字段中显示 personC。正如我们所知,不应显示密件抄送联系人 personC。为什么会发生这种情况?我正确地将CTCoreMessage
with 设置为、cc 和 bcc。这是MailCore
框架的错误吗?还是我错过了什么?
提前致谢!
以下是相关代码供大家参考
- (IBAction)buttonSendPressed:(id)sender
{
[self dismissViewControllerAnimated:YES completion:^{
CTCoreMessage *testMsg = [[CTCoreMessage alloc] init];
NSMutableArray *mutArrTos = [NSMutableArray array]; // personA
NSMutableArray *mutArrCcs = [NSMutableArray array]; // personB
NSMutableArray *mutArrBccs = [NSMutableArray array]; // personC
NSLog(@"toContactArr :%@",toContactArr);
if (toContactArr.count>0) {
for (NSDictionary *dict in toContactArr) {
[mutArrTos addObject:[CTCoreAddress addressWithName:[dict valueForKey:@"name"] email:[dict valueForKey:@"email"]]];
}
NSLog(@"mutArrRecipients : %@", mutArrTos);
[testMsg setTo:[NSSet setWithArray:mutArrTos]];
}
if (ccContactArr.count>0) {
for (NSDictionary *dict in ccContactArr) {
[mutArrCcs addObject:[CTCoreAddress addressWithName:[dict valueForKey:@"name"] email:[dict valueForKey:@"email"]]];
}
NSLog(@"mutArrRecipients : %@", mutArrCcs);
[testMsg setCc:[NSSet setWithArray:mutArrCcs]];
}
if (bccContactArr.count>0) {
for (NSDictionary *dict in bccContactArr) {
[mutArrBccs addObject:[CTCoreAddress addressWithName:[dict valueForKey:@"name"] email:[dict valueForKey:@"email"]]];
}
NSLog(@"mutArrRecipients : %@", mutArrBccs);
[testMsg setBcc:[NSSet setWithArray:mutArrBccs]];
}
[testMsg setFrom:[NSSet setWithObject:[CTCoreAddress addressWithName:@"222222" email:@"letibe.xx@gmail.com"]]];
[testMsg setBody:self.textView.text];
[testMsg setSubject:self.textField.text];
DbManager *dbManager = [[DbManager sharedManager] switchDBWithFileName:DBNAME];
User *user = [dbManager getAccount];
NSString *account = user.account;
NSString *pwd = user.password;
NSString *emailType = user.email_type;
NSLog(@"user: %@", user);
NSLog(@"account: %@", account);
NSLog(@"pwd: %@", pwd);
NSLog(@"emailType: %@", emailType);
NSError *error;
BOOL success = [CTSMTPConnection sendMessage:testMsg server:@"smtp.gmail.com" username:@"letibe.xx@gmail.com" password:@"222222" port:25 useTLS:YES useAuth:YES error:&error];
if (!success) {
// Present the error
NSLog(@"error: %@", error);
}else{
NSLog(@"CTSMTPConnection success");
}
}];
}