Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I set To and Subject fields in an E-Mail being sent by UIDocumentInteractionController?

I'm sending an email, with a PDF attachment, while using UIDocumentInteractionController, like this:

I start by showing the PDF file

-(void)showPDFFile
{    
    NSURL *url = [NSURL fileURLWithPath:_filePath];

    if (url) {
        _documentInteractionController =
            [UIDocumentInteractionController interactionControllerWithURL:url];

        [_documentInteractionController setDelegate: self];
        [_documentInteractionController presentPreviewAnimated:YES];
    }
}


- (UIDocumentInteractionController *)setupControllerWithURL:(NSURL *)fileURL
                                              usingDelegate:(id <UIDocumentInteractionControllerDelegate>)interactionDelegate {

    UIDocumentInteractionController *interactionController =
        [UIDocumentInteractionController interactionControllerWithURL: fileURL];

    [interactionController setDelegate: interactionDelegate];
    return interactionController;
}

When the PDF file is shown, the user clicks the "Export" option and the iOS's "Open with" view appears.

Clicking the email now opens a View Controller ready to send an email.

How would I set the To: CC/BCC and Subject fields programatically?

Thank you!

like image 648
nmdias Avatar asked Nov 01 '22 16:11

nmdias


1 Answers

You can assign the mail's subject by using the UIDocumentInteractionController name property:

_documentInteractionController.name = @"My custom mail subject";

Unfortunately this is the only attribute I've figured out that can be configured via UIDocumentInteractionController.

like image 188
Florian Mielke Avatar answered Nov 14 '22 03:11

Florian Mielke