How to add vcardfile to iPhone application composer sheet

in the mail sheet they can add images, but where they cannot connect the vcard file

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; picker.mailComposeDelegate = self; [picker addAttachmentData:ExportVCF mimeType:@"text/x-vcard" fileName:@ "JOHNSMITH.vcf"]; 

but when I send mail, I do not receive the attachment

+4
source share
3 answers

From the documentation for MFMailCompserViewController:

MIME type of the specified data. (For example, the MIME type for a JPEG image / jpeg image.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/ . This parameter must not be zero.

If you look at the link, you will see all valid MIME types, and text/x-vcard not specified. I think this means that the Mail composer view controller will not allow you to attach a file with an invalid (in his opinion) MIME type.

+1
source

According to the updates in MIME types 2014-08-04

http://www.iana.org/assignments/media-types/media-types.xhtml

vcard text/vcard format allows you to attach a vcf-vcard file.

 MFMailComposeViewController *mailer = [[MFMailComposeViewController alloc] init]; mailer.mailComposeDelegate = self; [mailer setSubject:@"vCard"]; [mailer addAttachmentData:data mimeType:@"text/vcard" fileName:@"File.vcf"]; [self presentModalViewController:mailer animated:YES]; 

enter image description here

+1
source

Update based on Wikipedia's business card page :

The standard type of Internet media for vCard (often called the MIME type):

 text/vcard 

Starting with version 4.0, other types of media that were previously used earlier are now outdated, including:

 text/x-vcard text/directory;profile=vCard text/directory 
0
source

Source: https://habr.com/ru/post/1300292/


All Articles