[HOW TO]如何在iPhone应用程序中发送邮件
2009-10-28 23:22
351 查看
3.0以前使用mailto URL,但是会退出当前应用程序
3.0后Apple提供了MessageUI framework可以在我们的应用程序内实现邮件发送功能,代码示范参见:
https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html
可以添加附件和以HTML格式发送邮件。
如果想要在邮件中添加URL如:http://ditu.at/tinyurl
可以如下编码:
// Fill out the email body text
NSString *emailBody = [[NSString alloc]init];
NSArray *arSubviews = [shareView subviews];
UITextField *tvMessage = [arSubviews objectAtIndex:4];
emailBody = [NSString stringWithFormat:@"%@,%@ <a href = '%@'>%@</a>", tvMessage.text, NSLocalizedString(@"FOR_DETAILS",@""),
[self.tinyURLList objectAtIndex:0],[self.tinyURLList objectAtIndex:0]];
如果想在邮件中提供你的App Store应用程序链接,可如下编码:
NSString *pageLink = @"http://mugunthkumar.com/yourapp";
NSString *iTunesLink = @"http://link-to-yourapp";
NSString *emailBody =
[NSString stringWithFormat:@"%@/n/n<h3>Sent from <a href = '%@'>your app</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", @"test url", pageLink, iTunesLink];
记住使用HTML格式:
[mailPicker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:mailPicker animated:YES];
3.0后Apple提供了MessageUI framework可以在我们的应用程序内实现邮件发送功能,代码示范参见:
https://developer.apple.com/iphone/library/samplecode/MailComposer/index.html
可以添加附件和以HTML格式发送邮件。
如果想要在邮件中添加URL如:http://ditu.at/tinyurl
可以如下编码:
// Fill out the email body text
NSString *emailBody = [[NSString alloc]init];
NSArray *arSubviews = [shareView subviews];
UITextField *tvMessage = [arSubviews objectAtIndex:4];
emailBody = [NSString stringWithFormat:@"%@,%@ <a href = '%@'>%@</a>", tvMessage.text, NSLocalizedString(@"FOR_DETAILS",@""),
[self.tinyURLList objectAtIndex:0],[self.tinyURLList objectAtIndex:0]];
如果想在邮件中提供你的App Store应用程序链接,可如下编码:
NSString *pageLink = @"http://mugunthkumar.com/yourapp";
NSString *iTunesLink = @"http://link-to-yourapp";
NSString *emailBody =
[NSString stringWithFormat:@"%@/n/n<h3>Sent from <a href = '%@'>your app</a> on iPhone. <a href = '%@'>Download</a> yours from AppStore now!</h3>", @"test url", pageLink, iTunesLink];
记住使用HTML格式:
[mailPicker setMessageBody:emailBody isHTML:YES];
[self presentModalViewController:mailPicker animated:YES];
相关文章推荐
- iPhone How-to:如何发送邮件
- How to send mail using C++ &amp;amp;amp; CAsyncSocket - SourceCode - 用C++ &amp;amp;amp; CAsyncSocket 如何发送邮件 - 源码 - HackerJLY
- How to send mail using VBScript & JMail - SourceCode - 如何用VBScript & JMail 发送邮件 - 源码
- 如何在iPhone应用程序中发送邮件
- How to send mail using any email account through Foxmail ? - Foxmail 6 漏洞,如何通过 Foxmail 用任意邮件账号发送邮件?
- iPhone How-to:如何更改UISwitch的提示文本
- prjSendMailInUniversity - How to send email using VB &amp; Winsock - 邮件发送接收程序 - VB6 + Winsock
- iPhone How-to:如何移除发布版本中的NSLog输出
- Android: How to share with Email (如何用邮件分享信息)
- iPhone How-to:如何调整UIView的Z-Order
- iPhone How-to:如何更改UISwitch的提示文本
- How to Write a simple UEFI EDKII Application:如何编写一个UEFI简单的应用程序[5]
- CP How-To:如何使用cPanel添加邮件帐号
- iPhone开发:如何阻止文件被iTunes和iCloud同步 How do I prevent files from being backed up to iCloud and iTunes?
- How to add icon for the item of ListCtrl using C++ (Mail Attachment ListCtrl) - 如何用C++为ListCtrl的Item添加图标(邮件附件ListCtrl)
- iPhone How-to:如何更改UISwitch的提示文本
- iPhone How-to:如何调整UIView的Z-Order
- iPhone How-to:如何递归dump UIView
- [How to] 如何开始iphone的程序开发.
- How to statically link Qt 4.6.0 (如何静态编译发布Qt应用程序)