iPhone中撰写邮件中文件的附件 [英] attachment of file in compose mail in iphone

查看:56
本文介绍了iPhone中撰写邮件中文件的附件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在制作一个基于窗口的应用程序.在此,我已经放置了一些记录,成为一个人的记录,现在我已将mailcomposer发送给邮件,但我想自动将该记录发送到该人的附件中.我可以在iPhone应用程序的mailcomposer中设置文档或excel文件.

I am making a window based application. In this I have put some entries which become record for one person now I have put mailcomposer to send mail but I want to send the record in mail of that person in attachment automatically. Can I set document or excel file in mailcomposer in iphone application.

如果有人知道,请帮助我.

If anyone know please help me.

非常感谢.

推荐答案

MFMailComposeViewController 协议定义了所需的方法.使用方法

The MFMailComposeViewController protocol defines the method you need. Using the method

- (void)addAttachmentData:(NSData *)attachment mimeType:(NSString *)mimeType fileName:(NSString *)filename __OSX_AVAILABLE_STARTING(__MAC_NA,__IPHONE_3_0);

您可以轻松地将任何类型的文件添加为邮件的附件.最简单的方法是合并您存储在CSV字符串中的记录,并将数据存储在ass附件中.参见以下示例:

you can easily add any kind of file as an attachment to the mail. The easiest way would be to combine the records you stored in an CSV string and store data inside ass attachment. See below for an example:

MFMailComposeViewController *picker = [[[MFMailComposeViewController alloc] init] autorelease];
[picker setSubject:@"New Contacts"];
NSMutableString *body = [[NSMutableString alloc] init];
[body appendString:@"Hi, see attachment\n\n"];


NSMutableString *csv = [[NSMutableString alloc] init];
// Add data to csv
// ...

[picker addAttachmentData:[csv dataUsingEncoding:NSStringEncodingConversionExternalRepresentation allowLossyConversion:NO]
                 mimeType:@"text/csv"
                 fileName: @"contacts.csv"];

这篇关于iPhone中撰写邮件中文件的附件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆