2014-01-10 29 views
2

我试图发送邮件列表我收到数据库的电子邮件数组,当我发送收件人列表填充iOS 7填充时,但当我在iOS 5尝试收件人列表不得到填充。任何想法为什么?这是我的邮件功能MFMailComposeViewController不填充收件人在ios 5

-(void)sendEmailToContacts:(NSArray *)fList withText:(NSString *)emailText withTag:(NSInteger)tag 
{ 
    if([MFMailComposeViewController canSendMail]) 
    { 
     MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init]; 
     mailComposer.view.tag=tag; 
     NSString *htmlBody =[NSString stringWithFormat:@"<a href=\"%@\">%@</a>",_currentAdd.contentUrl,addtext]; 
     [mailComposer setMessageBody:htmlBody isHTML:YES]; 
     [mailComposer setSubject:_currentMail.subject]; 
     mailComposer.mailComposeDelegate = self; 
     [mailComposer setToRecipients:fList]; 
     [self presentViewController:mailComposer animated:YES completion:nil]; 
    } 
    else 
    { 
     NSLog(@"Device is unable to send email in its current state."); 
    } 
} 

fList(收件人列表)是一个NSArray,这是我FLIST的样本输出

(
    "[email protected]", 
    "[email protected]", 
    "[email protected]", 
    "[email protected]" 
) 
+0

你能把breakpointed上sendEmailToContacts方法,并检查是否包含的flist指定的电子邮件列表,也可能是零? – ldindu

+0

它是iOS6的以上 – codercat

+0

我检查与断点作品中,包含的flist电子邮件,因为我已经张贴以上,它适用于ios7,我没有iOS6的SDK所以不知道它是否适合该 – Gamerlegend

回答

0
-(void)sendEmailToContacts:(NSArray *)fList withText:(NSString *)emailText withTag:(NSInteger)tag 
{ 
    if([MFMailComposeViewController canSendMail]) 
    { 
     MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init]; 
     //mailComposer.view.tag=tag; 
     NSString *htmlBody =[NSString stringWithFormat:@"<a href=\"%@\">%@</a>",_currentAdd.contentUrl,addtext]; 
     [mailComposer setMessageBody:htmlBody isHTML:YES]; 
     [mailComposer setSubject:_currentMail.subject]; 
     mailComposer.mailComposeDelegate = self; 
     [mailComposer setToRecipients:fList]; 
     [self presentViewController:mailComposer animated:YES completion:nil]; 
    } 
    else 
    { 
     NSLog(@"Device is unable to send email in its current state."); 
    } 
} 

显然,问题是用设置标签,如果我尝试设置标记之前setToRecipients行不会显示在iOS 5中的收件人列表,它会工作,如果设置标签行注释掉或setToRecipients之后设置。

0

收件人预计为不可变的数组。检查阵列类型

NSArray *usersTo = [NSArray arrayWithObject: @"[email protected]"]; 
    [mailComposer setToRecipients:usersTo]; 
+0

我通过如你所说的NSArray * FLIST =手动分配FLIST试图排除故障[NSArray的arrayWithObject:@“[email protected]”];但直到现在我还同一个问题,它适用于iOS7而不是在iOS5中 – Gamerlegend

0

试试这个。

 NSArray *fList = [NSArray arrayWithObjects:@"[email protected]",@"[email protected]",@"[email protected]",@"[email protected]",@"[email protected]", nil]; 

     MFMailComposeViewController *mailComposer = [[MFMailComposeViewController alloc] init]; 
     mailComposer.view.tag=tag; 
     NSString *htmlBody =[NSString stringWithFormat:@"<a href=\"%@\">%@</a>",_currentAdd.contentUrl,addtext]; 
     [mailComposer setMessageBody:htmlBody isHTML:YES]; 
     mailComposer.mailComposeDelegate = self; 
     [mailComposer setSubject:_currentMail.subject]; 
     mailComposer.delegate = self; 
     [mailComposer setToRecipients:fList]; 
     [self presentViewController:mailComposer animated:YES completion:nil]; 
+0

是什么mailComposeViewController在这里mailComposeViewController.mailComposeDelegate? – Gamerlegend

+0

不需要写那个@Gamerlegend – Maul

+0

是的,我这样做,但仍然没有为iOS 5工作 – Gamerlegend

相关问题