如何在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/