我使用以下代码发送邮件:

- (IBAction)sendMailPressed:(id)sender
{
    Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
    if (mailClass != nil)
    {
        // We must always check whether the current device is configured for sending emails
        if ([mailClass canSendMail])
        {
            [self displayComposerSheet];
        }
        else
        {
            [self launchMailAppOnDevice];
        }
    }
    else
    {
        [self launchMailAppOnDevice];
    }
}

// Displays an email composition interface inside the application. Populates all the Mail fields.
-(void)displayComposerSheet
{
    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
    picker.mailComposeDelegate = self;


    [picker setSubject:self.strMailSubject];

    // Attach pdf to the email
    NSURL *urlToLoad = [[NSBundle mainBundle] URLForResource:self.strSorce withExtension:self.strExtention];
    NSData *myData = [NSData dataWithContentsOfURL:urlToLoad];
    [picker addAttachmentData:myData mimeType:@"application/pdf" fileName:[NSString stringWithFormat:@"%@.%@", self.strSorce, self.strExtention]];

    //  [self presentModalViewController:picker animated:YES];
    [[Singleton sharedInstance] pushModalViewController:picker whereCurrentController:self animated:YES];
    [picker release];
}


// Dismisses the email composition interface when users tap Cancel or Send. Proceeds to update the message field with the result of the operation.
- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error
{
    // Notifies users about errors associated with the interface
    switch (result)
    {
        case MFMailComposeResultCancelled:
            break;
        case MFMailComposeResultSaved:
            break;
        case MFMailComposeResultSent:

            break;
        case MFMailComposeResultFailed:
            break;
        default:
            break;
    }

    [[Singleton sharedInstance] popModalViewControllerAnimated:YES];
}


// Launches the Mail application on the device.
-(void)launchMailAppOnDevice
{
    NSString *recipients = [NSString stringWithFormat:@"mailto:&subject=%@", self.strMailSubject];

    NSString *email = [NSString stringWithFormat:@"%@", recipients];
    email = [email stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];

    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];
}

我得到这样的看法:

但是我需要这种视图(请注意,仅注意From string,而不是image)。

我不知道如何使From字符串出现

最佳答案

您可以在代码中为此使用setCcRecipients:

10-08 03:11