iphone:如何在iPhone Ebook App中添加电子邮件功能

iphone:如何在iPhone Ebook App中添加电子邮件功能,第1张

概述我正在开发iPhone电子书应用程序. 在我的应用中,书籍是使用HTML创建的. 在Index.html页面中,我必须发送电子邮件(发送)特定章节内容的电子邮件功能. 现在通过使用webview我显示index.html,并且我创建了UIActionSheet,它将显示Email按钮. 请建议我如何识别要发送的不同链接的索引 特定章节的电子邮件. 即使您未在设备中配置电子邮件,下面的代码仍然有效. 我正在开发iPhone电子书应用程序.

在我的应用中,书籍是使用HTML创建的.
在Index.HTML页面中,我必须发送电子邮件(发送)特定章节内容的电子邮件功能.

现在通过使用webvIEw我显示index.HTML,并且我创建了UIActionSheet,它将显示Email按钮.

请建议我如何识别要发送的不同链接的索引
特定章节的电子邮件.

解决方法 即使您未在设备中配置电子邮件,下面的代码仍然有效.

这是代码:

- (IBAction) sendEmail:(ID)sender{    Class mailClass = (NSClassFromString(@"MFMailComposeVIEwController"));if (mailClass != nil){    // We must always check whether the current device is configured for sending emails    if ([mailClass canSendMail])    {        [self displayComposerSheet];    }    else    {        [self launchMailAppOnDevice];    }}else{    [self launchMailAppOnDevice];}}-(voID)displayComposerSheet {    MFMailComposeVIEwController *picker = [[MFMailComposeVIEwController alloc] init];    picker.mailComposeDelegate = self;    [picker setSubject:@"Hello from DShah!"];    NSArray *toRecipIEnts = [NSArray arrayWithObject:@"first@example.com"];     NSArray *ccRecipIEnts = [NSArray arrayWithObjects:@"second@example.com",@"third@example.com",nil];     NSArray *bccRecipIEnts = [NSArray arrayWithObject:@"fourth@example.com"];     [picker setToRecipIEnts:toRecipIEnts];    [picker setCcRecipIEnts:ccRecipIEnts];      [picker setBccRecipIEnts:bccRecipIEnts];    Nsstring *path = [[NSBundle mainBundle] pathForResource:@"userdata" ofType:@"abc"];    NSfileManager *fileManager = [NSfileManager defaultManager];    NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES);    Nsstring *documentsDirectory = [paths objectAtIndex:0];    Nsstring *fullPath = [documentsDirectory stringByAppendingPathComponent:[Nsstring stringWithFormat:@"%@.abc",@"userdata"]];     NSData *myData = [NSData dataWithContentsOffile:fullPath];    [picker addAttachmentData:myData mimeType:@"csv" filename:@"userdata.abc"];    Nsstring *emailBody = @"It is raining in sunny California!";    [picker setMessageBody:emailBody isHTML:NO];    [self presentModalVIEwController:picker animated:YES];    [picker release];}-(voID)launchMailAppOnDevice{    Nsstring *recipIEnts = @"mailto:first@example.com&subject=Hello from DShah!";    Nsstring *body = @"&body=It is cold in Winter!";    Nsstring *email = [Nsstring stringWithFormat:@"%@%@",recipIEnts,body];    email = [email stringByAddingPercentEscapesUsingEnCoding:NSUTF8StringEnCoding];    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:email]];}

然后实现Delegate方法如下….

- (voID)mailComposeController:(MFMailComposeVIEwController*)controller dIDFinishWithResult:(MFMailComposeResult)result error:(NSError*)error {    switch (result)    {        case MFMailComposeResultCancelled:            message = @"Result: canceled";            break;        case MFMailComposeResultSaved:            message = @"Result: saved";            break;        case MFMailComposeResultSent:            message = @"Result: sent";            break;        case MFMailComposeResultFailed:            message = @"Result: Failed";            break;        default:            message = @"Result: not sent";            break;    }    UIAlertVIEw *alert = [[UIAlertVIEw alloc] initWithTitle:@"Email Demo" message:message delegate:nil cancelbuttonTitle:@"OK" otherbuttonTitles:nil,nil];    [alert show];    [alert release];    [self dismissModalVIEwControllerAnimated:YES];}
总结

以上是内存溢出为你收集整理的iphone:如何在iPhone Ebook App中添加电子邮件功能全部内容,希望文章能够帮你解决iphone:如何在iPhone Ebook App中添加电子邮件功能所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1067461.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-26
下一篇 2022-05-26

发表评论

登录后才能评论

评论列表(0条)

保存