2012-03-11 4 views
1

내 프로그램에서 런타임에 이미지를 수정하면 전자 메일로 보내야합니다. 장치에 보관할 필요가 없습니다. 어떤 제안? 이미지가 마일 아이폰 = (UIImage 이메일로 보내기

- (void)emailImage{ 


    MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init]; 
    picker.mailComposeDelegate = self; 

    // Set the subject of email 
    [picker setSubject:@"MI FOTO FINAL"]; 

    // Fill out the email body text 
    NSString *emailBody = @"Foto final"; 

    // This is not an HTML formatted email 
    [picker setMessageBody:emailBody isHTML:NO]; 


    NSData *data = UIImagePNGRepresentation(Foto.image); 

    [picker addAttachmentData:data mimeType:@"image/png" fileName:@"ImagenFinal"]; 

    // [picker addAttachmentData:data mimeType:nil fileName:nil]; 


    // Show email view 
    [self presentModalViewController:picker animated:YES]; 

}

+0

전화로 이메일 계정을 올바르게 구성 했습니까? – Alexander

답변

2

당신은 당신의 UIImage에서 PNG 형식의 데이터를 추출 UIImagePNGRepresentation() 기능을 사용할 수 있습니다에 저장되지 않기 때문에

내가이 아니라 작품을 사용합니다.

+0

나는 아이폰에 저장하지 않았기 때문에이 새로운 이미지에서 작동하지 않지만 다른 아이디어가 있습니까? – marduck19

+0

감사합니다. 오류가 있고 답이 괜찮습니다. – marduck19

5

이 하나를 시도 할 수 있습니다 이미지에있을 :.

UIImage *UIImageToSend; 
,

코드 및 코드

MFMailComposeViewController *composer = [[MFMailComposeViewController alloc] init]; 
[composer setMailComposeDelegate:self]; 
if([MFMailComposeViewController canSendMail]) { 
    [composer setToRecipients:[NSArray arrayWithObjects:@"[email protected]",nil]]; 
    [composer setSubject:@"A nice subject"]; 
    [composer setMessageBody:@"Hi,\n\nI'm sending you this beautiful photograph." isHTML:NO]; 
    [composer setModalTransitionStyle:UIModalTransitionStyleCrossDissolve]; 

    NSData *data = UIImageJPEGRepresentation(UIImageToSend,1); 
    [composer addAttachmentData:data mimeType:@"image/jpeg" fileName:@"Photograph.jpg"]; 

    [self presentModalViewController:composer animated:YES]; 
} 
관련 문제