Search code examples
iphoneobjective-cattachmentmfmailcomposeviewcontrollervcf-vcard

how to add .vcf file as attachment in application iphone


In my app I want to add .vcf file as attachment in MFMailComposeViewController.


Solution

  • The documentation for MFMailComposeViewController shows that its addAttachmentData:mimeType:fileName: instance method is the way to go:

    - (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
    

    The attachment is the actual vcf file loaded or transformed into NSData.

    The mimeType for a vcf is @"text/x-vcard".

    The fileName is whatever you want to call it, though you should uses the .vcf extension to ensure that email programs will understand it.