【问题标题】:How to add attchment and signature in email through programming in iPhone App/如何通过 iPhone App 中的编程在电子邮件中添加附件和签名/
【发布时间】:2012-03-15 11:42:48
【问题描述】:

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

【问题讨论】:

标签: iphone html ios email


【解决方案1】:

发送附件:您可以使用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];
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-04
    • 1970-01-01
    • 2018-01-04
    • 2015-06-07
    • 1970-01-01
    相关资源
    最近更新 更多