2

データベースから受信した電子メール配列のリストにメールを送信しようとしていますが、送信すると受信者リストが入力されますが、受信者リストiOS 7を試しても入力され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のサンプル出力です

(
    "john@gmail.com",
    "mary@gmail.com",
    "akhil@gmail.com",
    "tester@gmail.com"
)
4

3 に答える 3

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 では受信者リストが表示されません。

于 2014-01-14T04:42:07.160 に答える
0

受信者は不変の配列として期待されます。配列タイプを確認してください

  NSArray *usersTo = [NSArray arrayWithObject: @"raja@apple.com"];
    [mailComposer setToRecipients:usersTo];
于 2014-01-10T09:51:55.857 に答える
0

これを試してみてください。

        NSArray *fList = [NSArray arrayWithObjects:@"raja@apple.com",@"john@gmail.com",@"mary@gmail.com",@"akhil@gmail.com",@"tester@gmail.com", 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];
于 2014-01-10T10:12:00.923 に答える