iphone - 如何使用 iPhone 通过 SMTP 发送带附件的邮件

标签 iphone ipad email smtp

我是 Iphone 开发新手,谁能帮我获取使用 iPhone 通过 SMTP 发送带有附件的邮件的示例代码。

我已经尝试了以下 URL 中的示例代码

http://code.google.com/p/skpsmtpmessage/

谢谢

最佳答案

以下是通过邮件附加文件的示例代码。

MFMailComposeViewController *picker = [[MFMailComposeViewController alloc] init];
picker.mailComposeDelegate = self;

[picker setSubject:@"Hello"];


// Set up recipients
NSArray *toRecipients = [NSArray arrayWithObject:@"first@example.com"]; 
NSArray *ccRecipients = [NSArray arrayWithObjects:@"second@example.com", @"third@example.com", nil]; 
NSArray *bccRecipients = [NSArray arrayWithObject:@"fourth@example.com"]; 

[picker setToRecipients:toRecipients];
[picker setCcRecipients:ccRecipients];  
[picker setBccRecipients:bccRecipients];

// Attach an image to the email
NSString *path = [[NSBundle mainBundle] pathForResource:@"rainy" ofType:@"png"];
NSData *myData = [NSData dataWithContentsOfFile:path];
[picker addAttachmentData:myData mimeType:@"image/png" fileName:@"myFile"];

// Fill out the email body text
NSString *emailBody = @"Message body : my first email sending ";
[picker setMessageBody:emailBody isHTML:NO];

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

关于iphone - 如何使用 iPhone 通过 SMTP 发送带附件的邮件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5832620/

相关文章:

c# - 在 C# 中发送电子邮件

email - 退出邮件编辑器后应用程序崩溃

iphone - 当我在模拟器上运行iPhone应用程序时,屏幕为白色

iphone - 如何确定一组特定实验值的比例因子

ios - 由于 FirebaseApp.configure() 导致的 SIGABRT 错误

ios - 是否可以使用 UIKit 创建 PDF 表单

iphone - ios 中的错误(com.facebook.sdk 错误 5.)

iphone - 如何更改所有 UITableViewCells 的背景颜色

iphone - 在 ipad 中弹出窗口两次显示用户当前位置

java - IMAP IDLE 库