2010-07-17 64 views
2

我想使用Mail Composer,它應該附加一個圖像文件,這是如何實現的?如何在Mail Composer中附加圖片?

+0

可能重複的[iPhone - 我如何從我的應用程序中嵌入圖像電子郵件?](http://stackoverflow.com/questions/819021/iphone-how-can-i-embed-images-in-email-從-MY-APP) – kennytm 2010-07-17 07:33:37

回答

2

它可以附加一個圖像測試代碼在另一個答案提供應該工作,但作爲第二個來源相同的代碼位於Apress在這個URL Mail Pic應該能夠幫助你一個工作的例子。下載該文件夾並打開項目文件的MailPic文件夾。

15

您可以測試這個代碼,它的工作完美...

MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init]; 

    mailController.mailComposeDelegate = self; 

    [mailController setSubject:@"Hello iPhone"]; 

    [mailController setMessageBody:@"This is the MailSend Application...." isHTML:NO]; 

    UIImage *pic = [UIImage imageNamed:@"Image box with border-1.png"]; 
    NSData *exportData = UIImageJPEGRepresentation(pic ,1.0); 
    [mailController addAttachmentData:exportData mimeType:@"image/jpeg" fileName:@"Picture.jpeg"]; 


    [self presentModalViewController:mailController animated:YES]; 
    [mailController release]; 
} 

- (void)mailComposeController:(MFMailComposeViewController*)mailController 

didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 

{ 

     [self becomeFirstResponder]; 

    [self dismissModalViewControllerAnimated:YES]; 

} 

更多信息與示例代碼檢查這裏

http://iosrider.wordpress.com/2012/01/06/how-to-add-email-and-message-in-your-native-application/

相關問題