iPhone 的邮件发送框架

发布于 2024-09-11 03:04:43 字数 101 浏览 1 评论 0原文

我想从带有自定义 UI 的 iPhone 应用程序发送带有附件的电子邮件。我可以用什么来实现这个目的?

UPD:也许可以使用一些 smtp 库来完成此任务?你有什么建议?

I want to send emails with attachments from my iphone application with custom UI. What can i use for this?

UPD: maybe it's possible to use some smtp library for this task? What can you advice?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

丿*梦醉红颜 2024-09-18 03:04:43

你需要执行以下操作
首先通过右键单击项目添加一个框架。
添加->现有框架->
库/框架/MessageUI.framework

然后是
在ViewController.h文件中

#import <MessageUI/MessageUI.h>

@interface ViewController : UIViewController  <UITextFieldDelegate, MFMailComposeViewControllerDelegate>{
//....yor variables
}

ViewController.m文件

- (void)viewDidLoad {

[super viewDidLoad];

self.title = @"Sample Email Application"; // title of navigation bar

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]  initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(composeMail:)] autorelease]; // for adding a compose button 
//in navigation bar.
//...your code 
}


-(void) composeMail: (id) sender{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;

[[picker navigationBar] setTintColor:[UIColor blackColor]];


[picker setSubject:@"Sample Email Application"];
[picker setMessageBody:[NSString stringWithFormat:@"Visit for more help %@. ",@"http://google.com"] isHTML:YES];

[self presentModalViewController:picker animated:YES];
[picker release];
}



- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
[controller dismissModalViewControllerAnimated:YES];
}

you need to do the following
first add a framework by right clicking on project.
Add -> Existing Framework ->
library/frameworks/MessageUI.framework

then
in ViewController.h file

#import <MessageUI/MessageUI.h>

@interface ViewController : UIViewController  <UITextFieldDelegate, MFMailComposeViewControllerDelegate>{
//....yor variables
}

ViewController.m file

- (void)viewDidLoad {

[super viewDidLoad];

self.title = @"Sample Email Application"; // title of navigation bar

self.navigationItem.rightBarButtonItem = [[[UIBarButtonItem alloc]  initWithBarButtonSystemItem:UIBarButtonSystemItemCompose target:self action:@selector(composeMail:)] autorelease]; // for adding a compose button 
//in navigation bar.
//...your code 
}


-(void) composeMail: (id) sender{
MFMailComposeViewController *picker = [[MFMailComposeViewController alloc]init];
picker.mailComposeDelegate = self;

[[picker navigationBar] setTintColor:[UIColor blackColor]];


[picker setSubject:@"Sample Email Application"];
[picker setMessageBody:[NSString stringWithFormat:@"Visit for more help %@. ",@"http://google.com"] isHTML:YES];

[self presentModalViewController:picker animated:YES];
[picker release];
}



- (void)mailComposeController:(MFMailComposeViewController*)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError*)error 
{
[controller dismissModalViewControllerAnimated:YES];
}

您需要在自己的 SMTP 服务器中进行编译,网上有一些可以使用的服务器。这是一堆伤害。只需使用 iPhone 的标准消息编辑器即可。除非您正在构建一个电子邮件垃圾邮件客户端,否则这不会真正起作用。

You will need to compile in your own SMTP server, there are a few online that work. This is a pile of hurt. Just use the iPhones Message Composer which is standard. Unless you are building a email spam client this wont really work.

回梦 2024-09-18 03:04:43

如果您想在不使用本机邮件编辑器 UI 且不设置自己的 SMTP 服务器的情况下发送电子邮件,您可以查看 PostageApp (http: //postageapp.com/)。有一个 iOS / Mac API 包装器,可让您通过 API 发送电子邮件。 https://github.com/postageapp/postageapp-objc

(披露:我为 PostageApp 工作,开发了该插件。)

If you want to send email without using the native mail composer UI and without setting up your own SMTP server, you can check out PostageApp (http://postageapp.com/). There's an iOS / Mac API wrapper that lets you send email through the API. https://github.com/postageapp/postageapp-objc

(Disclosure: I work for PostageApp and developed the plugin.)

您的好友蓝忘机已上羡 2024-09-18 03:04:43

开源 third20 框架通过模仿原始邮件应用程序的 TTMessageController 设计了自己的邮件功能。您可以使用它作为起点,然后只需修改 UI它符合您的需求。

不过,通过电子邮件发送附件是另一回事...

更多信息:http://www. Three20.info/overview< /a>

The open source three20 framework has designed it's own Mail capabilities via TTMessageController which mimics the original Mail app..You can use that as a starting point and then simply modify the UI of it to your needs.

E-mailing attachments is another story though...

More information: http://www.three20.info/overview

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文