0

を使用してMFMailComposerViewController、iOS アプリからメールを送信しています。画像を追加しようとする場合を除いて、メールは機能します。私にとっての画像の問題は、それを使用して取得することです

次のようなものを使用する他の例を見てきました: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];
4

3 に答える 3

0

使用する必要があります

- (void)addAttachmentData:(NSData*)attachment mimeType:(NSString*)mimeType fileName:(NSString*)filename
Parameters
attachment
The data to attach. Typically, this is the contents of a file that you want to include. This parameter must not be nil.
mimeType
The MIME type of the specified data. (For example, the MIME type for a JPEG image is image/jpeg.) For a list of valid MIME types, see http://www.iana.org/assignments/media-types/. This parameter must not be nil.
filename
The preferred filename to associate with the data. This is the default name applied to the file when it is transferred to its destination. Any path separator (/) characters in the filename are converted to underscore (_) characters prior to transmission. This parameter must not be nil.
Discussion
This method attaches the specified data after the message body but before the user’s signature. You may attach multiple files (using different file names) but must do so prior to displaying the mail composition interface. Do not call this method after presenting the interface to the user.

Availability
Available in iOS 3.0 and later.

フォームMFMailComposeViewControllerクラス リファレンス

于 2013-05-22T10:15:36.880 に答える
0

この行を使用して画像を添付するだけです。

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

[mailComposer addAttachmentData:data mimeType:@"image/png" fileName:@"image.png"];
于 2013-05-22T11:51:27.497 に答える