简体   繁体   English

从相机发送带有图像附件的邮件

[英]Send mail with image attachment from camera

There are a LOT of tutorials and info about how to send attachment with your iphone / ipad app, but with pre-defined images or other file-type. 关于如何使用iphone / ipad应用程序发送附件,但附带了预定义的图像或其他文件类型,有很多教程和信息。 But how do i send an mail with a current file from my iphone/ipad. 但是,如何从iPhone / iPad发送带有当前文件的邮件。 More specific, an image or image from camera? 更具体地说,是图像还是来自相机的图像?

Cheers and thank you 干杯,谢谢

If you are using UIImagePickerController to capture image than when you capture image : 如果您使用的是UIImagePickerController来捕获图像,而不是在捕获图像时:

  #import <MobileCoreServices/UTCoreTypes.h> // framework MobileCoreServices.framework

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{    
    NSString *mediaType = [info objectForKey:UIImagePickerControllerMediaType];
    if ([mediaType isEqualToString:(NSString *)kUTTypeImage])
    {
        UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];
        [self sendMailWithImage:image];
    }
    [picker dismissModalViewControllerAnimated:NO];
}

- (void)sendMailWithImage:(UIImage *)image
{
     MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
     mailComposer.mailComposeDelegate = self;         
     // make sure you can make NSData from the object
     [mailComposer addAttachmentData:UIImageJPEGRepresentation(image, 1.0) mimeType:@"image/jpg" fileName:@"what ever you want to call the file"];
     [self presentViewController:mailComposer animated:YES completion:nil];
}
MFMailComposeViewController * mailComposer = [[MFMailComposeViewController alloc]init];
mailComposer.mailComposeDelegate = self;
UIImage *myImage = // some code to get your image or what ever file you want
// make sure you can make NSData from the object
[mailComposer addAttachmentData:UIImageJPEGRepresentation(imageToShare, 1.0) mimeType:@"image/jpg" fileName:@"what ever you want to call the file"];
[self presentViewController:mailComposer animated:YES completion:nil];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从iPad发送带有附件的电子邮件 - How do I send an e-mail with attachment from iPad 如何将相机图像作为附件传递给邮件。 (Android,iOS,Windows Phone,Phonegap) - How to pass a camera image to mail as an attachment. (Android, iOS, Windows Phone, Phonegap) 来自相机或照片库MFmessage / MailcomposeViewController的图像附件 - image attachment from camera or photo library MFmessage/MailcomposeViewController 将图像从Camera发送到另一个ViewController - Send image from Camera to another ViewController Rails 4.2 - 将图像数据作为电子邮件附件发送而不保存图像 - Rails 4.2 - Send Image Data as Email Attachment Without Saving Image 从HTML正文创建PDF文件并作为邮件附件发送,iOS - Create PDF file from HTML Body and Sending as mail attachment, iOS 在iOS中从邮件附件打开Flex应用程序 - Opening flex application from mail's attachment in iOS pkpass 无法通过电子邮件附件在 iOS 上打开 - pkpass won't open on iOS from e-mail attachment 在iOS中使用Mail扩展名共享Mail App中的附件 - Share attachment from Mail App with Share extension in iOS 从mfmailcomposer发送附件时,无法查看邮件附件中的数据 - Not able to view the data in a attachment in mail when sending the attachments from mfmailcomposer
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM