如何在ios中将Web视图数据和图像视图数据添加到Mfmailcomposer视图控制器。 用于向他人发送邮件。
答案 0 :(得分:2)
你可以Firest创建一个imageFull路径数组你想用电子邮件学习,并且像下面这样: -
- (IBAction)sendemail
{
Class mailClass = (NSClassFromString(@"MFMailComposeViewController"));
if (mailClass != nil)
{
// We must always check whether the current device is configured for sending emails
if ([mailClass canSendMail])
{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;
[picker setSubject:@"Hello"];
//NSString *result = txtFiled.text;
for(NSString *dicsss in buttonss) // Hear buttonss its a ImagePathfull array
{
UIImage *imgvith = [UIImage imageWithContentsOfFile:[buttonss stringByAppendingPathComponent:dicsss]];
NSData *data = UIImagePNGRepresentation(imgvith);
[picker addAttachmentData:data mimeType:@"image/png" fileName:@"yourImagename"];
}
NSString *emailBody = @"Hi";
[picker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:picker animated:YES];
[picker release];
}
}
工作代码screenShot看起来像: -
答案 1 :(得分:0)
您可以使用
for (UIImage *yourImage in YourImageArray )
{
NSData *imgData = UIImageJPEGRepresentation(yourImage, 0.5);
[mfMailComposer addAttachmentData:imgData mimeType:@"image/jpeg" fileName:[NSString
stringWithFormat:@"a.jpg"]];
}
答案 2 :(得分:0)
最佳解决方案是
[mailCompose setMessageBody: msg isHTML: YES];
其中msg具有值:
<body>
<img src='http://your_site/image1.jpg'>
<img src='http://your_site/image2.jpg'>
<br/>
<font face='Arial' size='2'>
Message Text<br/>
<br/>
</font>
答案 3 :(得分:0)