我正在使用MFMailComposerViewController
從iOS應用發送電子郵件。郵件工作除了試圖添加圖像時。與我的形象的問題是讓它使用如何使用MFMailComposerViewController將UIImage添加到電子郵件?
我見過其他例子,使用類似的東西:UIImage *emailImage = [UIImage imageNamed:@"myImageName.png"];
添加圖像。我的形象是從使用[self.photo objectForKey:kPhotoPictureKey];
// mail
// Email Subject
NSString *emailTitle = @"Join. Download the iPhone app";
// Email Content
NSString *messageBody = @"http://www..com/";
// To address
NSArray *toRecipents = [NSArray arrayWithObject:@""];
UIImageView *mailImage = [[UIImageView alloc] init];
mailImage.image = [UIImage imageNamed:@"1.png"]; // placeholder image
mailImage.file = [self.photo objectForKey:kPhotoPictureKey];
[mailImage loadInBackground];
NSString *messageBody = [NSString stringWithFormat:@"http://www.example.com/<p><b><img src='data:image/png;base64,%@'></b></p>",mailImage.image];
MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
mc.mailComposeDelegate = self;
[mc setSubject:emailTitle];
[mc setMessageBody:messageBody isHTML:NO];
[mc setToRecipients:toRecipents];
// Present mail view controller on screen
[self presentViewController:mc animated:YES completion:NULL];
http://stackoverflow.com/questions/1527351/how-to-add-an-uiimage-in-mailcomposer-sheet-of-mfmailcomposeviewcontroller-in-ip –
**做適當的研究,你問前一個問題。** –