iphone - 如何通过iPhone App/中的编程在电子邮件中添加附件和签名

标签 iphone html ios email-integration

如何在iPhone应用程序iPhone的电子邮件中以编程方式将视频/图像/音频作为附件添加,如何添加签名?我认为可以通过使用html标签来完成,但是如何完成。您可以为此提供任何示例代码吗?
谢谢-

最佳答案

要发送附件,请执行以下操作:您可以使用MFMailComposeViewController从您的应用程序发送附件。

1. 添加MessageUI框架,并执行#import <MessageUI/MFMailComposeViewController.h>
2. 在您的电子邮件按钮操作中,或者在发送电子邮件时,添加:

if([MFMailComposeViewController canSendMail]) //IMPORTANT: check if mail can be sent to avoid crash
{
    MFMailComposeViewController*mailController=[[MFMailComposeViewController alloc] init];

    NSURL*yourUrl=[NSURL fileURLWithPath:yourFilePath];
    NSData*attachData=[NSData dataWithContentsOfURL:yourUrl];

    mailController.mailComposeDelegate=self;
    [mailController addAttachmentData:attachData mimeType:@"yourExtension" fileName:@"yourFileName.yourExtension"];
    [mailController setSubject:@"Test Subject"];
    [mailController setTitle:@"Test Title"];


    if(mailController!=nil)
    {
        [self presentModalViewController:mailController animated:YES];
    }

    [mailController release];
}

else //give a prompt showing no mail accounts found
{
    UIAlertView*emailAlert=[[UIAlertView alloc] initWithTitle:@"No Email Account Found." message:@"Please set an email account." delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil, nil];
    [emailAlert show];
    [emailAlert release];
}

设置签名:我想它使用相对于已设置的邮件帐户的签名。很抱歉不知道如何以编程方式进行更改。

关于iphone - 如何通过iPhone App/中的编程在电子邮件中添加附件和签名,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9718969/

相关文章:

iphone - Bonjour 在后台?

iphone - 以编程方式移动 xib 文件中的 UILabel

iphone - iOS:用于登录屏幕的表格样式 TextField?

ios - Xcode 版本 6.1 (6A1030) - Apple Mach O-Linker 错误 - 构建

iphone - NSPredicate 表达式中 SUBQUERY 的快速解释

iphone - 带有 sectionsNameKeyPath 和结果顺序的 NSFetchResultsController

html - 在 Windows 上调试 Ipad Web 应用程序

javascript - iframe 不适用于通配符包罗万象的子域和 dnsmasq

javascript - 无法在 html 表格的下拉列表中显示 JSON 数据

iOS App 不会使用自定义 iCloud 容器