0

I want to save, after user press send mail button, the mail addresses an user wrote. But even if it could be set the to recipient I don't know how to read from it (there aren't any properties, or better any read enabled one, related to toRecipient). Any suggestions?

esses
  • 1

2 Answers2

0

I don't think there is any way to do that.

Rayfleck
  • 12,116
  • 8
  • 48
  • 74
0

I find a way:

Code

MFMailComposeViewController *mViewController = [[MFMailComposeViewController alloc] init];

NSArray* listVues = [mViewController childViewControllers];
MFMailComposeViewController* mailContainer = [listVues objectAtIndex:0];
UIView* mailView = [[[mailContainer view] subviews] objectAtIndex:0];
UIScrollView* composer = [[mailView subviews] objectAtIndex:0];
UIView* composerFields = [[composer subviews] objectAtIndex:0];

for (UIView* item in [composerFields subviews])
{
    NSString* desc = [item description];
    if ([desc hasPrefix:@"<MFMailComposeRecipientView"] == YES)
    {
          for (UIView* subitem in [item subviews])
          {
                NSString* desc2 = [subitem description];
                if ([desc2 hasPrefix:@"<_MFMailRecipientTextField"] == YES)
                {
                        UITextView* txt = (UITextView*)subitem;
                }
           }
    }
    else
    if ([desc hasPrefix:@"MFComposeFromView"] == YES)
    {
                for (UIView* subitem in [item subviews])
                {
                    NSString* desc2 = [subitem description];
                    if ([desc2 hasPrefix:@"<UITextField"] == YES)
                    {
                        UITextView* txt = (UITextView*)subitem;
                    }
                }
    }
    else
    if ([desc hasPrefix:@"<MFComposeSubjectView"] == YES)
    {
          // ...
    }
    else
    if ([desc hasPrefix:@"<MFComposeMultiView"] == YES)
    {
          // ...
    }
}

Change one of the four " if ([desc hasPrefix:@"..."] == YES) " content according to any needs. You can save the [txt text] value to your own variable.

Dugh
  • 171
  • 1
  • 3