gpt4 book ai didi

iphone - 如何在 iPhone sdk 中将 HTML 页面附加到我的邮件编辑器?

转载 作者:行者123 更新时间:2023-11-28 03:33:32 24 4
gpt4 key购买 nike

我在 UIWebView 中显示了一个 html 文件。我需要将我的当前页面作为附件和附件作为 html 文件发送。我的代码,

-(void)mailClick
{
NSLog(@"mail");
if ([MFMailComposeViewController canSendMail])
{
//atableView.scrollEnabled=YES;
//[socailNetworkView removeFromSuperview];
// self.navigationItem.title = @"Contents";
MFMailComposeViewController *mailViewController = [[MFMailComposeViewController alloc] init];
mailViewController.mailComposeDelegate = self;
[mailViewController setSubject:@""];
NSString *fullPath =[[NSBundle mainBundle] pathForResource:@"first" ofType:@"html"];
NSData *myData = [NSData dataWithContentsOfFile:fullPath];
[mailViewController addAttachmentData:myData
mimeType:@"text/plain"
fileName:@"File_Name"];
[mailViewController setMessageBody:@"" isHTML:NO];
NSString *string = [NSString stringWithFormat:@"", nil];


NSArray *mailArr = [[NSArray alloc] initWithObjects:string,nil];
[mailViewController setToRecipients:mailArr];
[self presentModalViewController:mailViewController animated:YES];
[mailViewController release];

}

else
{

NSLog(@"Device is unable to send email in its current state");

}
}


- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error;

{

NSLog(@"Mail");
NSString *str=@"";
switch (result) {
case MFMailComposeResultCancelled:
NSLog(@"Mail send canceled.");
str=@"\nMail sending cancelled";
msgLabel.text=str;
[msgLabel setFont:[UIFont fontWithName:@"Arial" size:18]];
msgLabel.textColor=[UIColor colorWithRed:(54.0/255.0) green:(2.0/255) blue:(1.0/255) alpha:1.0];

/*
Execute your code for canceled event here ...
*/
break;
case MFMailComposeResultSaved:
NSLog(@"Mail saved.");
str=@"Mail saved";
/*
Execute your code for email saved event here ...
*/
break;
case MFMailComposeResultSent:
NSLog(@"Mail sent.");
str=@"Mail sent";
/*
Execute your code for email sent event here ...
*/
break;
case MFMailComposeResultFailed:
str=@"Mail not sent";
NSLog(@"Mail send error: %@.", [error localizedDescription]);
/*
Execute your code for email send failed event here ...
*/
break;
default:
break;
}

[self dismissModalViewControllerAnimated:YES];
}

使用此代码可以发送带有指定 html 文件(整个 html 文件)作为附件的邮件。并且正在以文本文档的形式收到邮件。现在我怎么能只发送我当前页面的邮件和附件作为 html 文件?提前致谢。

最佳答案

您必须将 mimeType 设置为 mimeType:@"text/html"。我认为没有其他方法可以将特定页面(当前页面)作为 MFMailComposer 中的附件发送。请参阅此 link设置 mimetype

关于iphone - 如何在 iPhone sdk 中将 HTML 页面附加到我的邮件编辑器?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16053359/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com