gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-12-03 19:59:31 24 4
gpt4 key购买 nike

我是 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/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com