答えて

3

documentation for MFMailComposeViewControllerはそのaddAttachmentDataことを示しています。MIMEタイプ:ファイル名:インスタンスメソッドを移動するための方法である:

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

添付はNSDataのにロードまたは形質転換実際のVCFファイルです。

vcfのmimeTypeは、@ "text/x-vcard"です。

ファイル名は、電子メールプログラムが理解できるように.vcf拡張子を使用してください。

+0

どのようにすべての連絡plsのためのiphoneでvcfファイルを作るのに役立ちます。 – parag

3

次のコードを使用してvcfファイルを作成し、ディレクトリに保存します。

ABAddressBookRef addressBook = ABAddressBookCreate(); 

//-------------------Creating and saving vcf -------------------------------- 
CFArrayRef contacts = ABAddressBookCopyArrayOfAllPeople(addressBook); 
CFDataRef vcards = (CFDataRef)ABPersonCreateVCardRepresentationWithPeople(contacts); 
NSString *vcardString = [[NSString alloc] initWithData:(NSData *)vcards encoding:NSUTF8StringEncoding]; 
NSError *error; 
NSFileManager *fileMgr = [NSFileManager defaultManager]; 
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); 
NSString *folderPath = [paths objectAtIndex:0]; 
NSString *filePath = [folderPath stringByAppendingPathComponent:@"contacts.vcf"]; 
[vcardString writeToFile:filePath atomically:YES encoding:NSUTF8StringEncoding error:nil]; 
NSLog(@"Documents directory: %@",[fileMgr contentsOfDirectoryAtPath: folderPath error:&error]); 
if (addressBook) { 
    CFRelease(addressBook); 
} 
関連する問題