首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >未收到使用MessageUI框架发送的电子邮件

未收到使用MessageUI框架发送的电子邮件
EN

Stack Overflow用户
提问于 2012-01-04 22:39:27
回答 1查看 762关注 0票数 0

我正在使用MessageUI框架发送电子邮件,但发送时从未收到过该电子邮件。

我正在导入#import <MessageUI/MessageUI.h>

然后我有了下面的代码

代码语言:javascript
复制
- (void)emailFile
{
if(![MFMailComposeViewController canSendMail]) {
    UIAlertView *cantSend = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Device not configured to send email" delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
       [cantSend show];
    [cantSend release];
} else {
    MFMailComposeViewController *mailView = [[[MFMailComposeViewController alloc] init] autorelease];
    mailView.mailComposeDelegate = self;
    [mailView setToRecipients:[NSArray arrayWithObject:@"matthew.inman@cdl.co.uk"]];
    [mailView setSubject:@"Test"];
    [mailView setMessageBody:@"This is a text message" isHTML:NO];
    [self presentModalViewController:mailView animated:YES];
}
}

代码语言:javascript
复制
- (void)mailComposeController:(MFMailComposeViewController *)controller didFinishWithResult:(MFMailComposeResult)result error:(NSError *)error
{
if(error) {
    UIAlertView *errorView = [[UIAlertView alloc] initWithTitle:@"Mail Error" message:[error localizedDescription] delegate:self cancelButtonTitle:nil otherButtonTitles:@"OK", nil];
    [errorView show];
    [errorView release];
} else {
    switch (result) {
        case MFMailComposeResultSent:
            NSLog(@"Sent Mail");
            break;
        case MFMailComposeResultSaved: 
            NSLog(@"Mail Saved");
            break;
        case MFMailComposeResultCancelled:
            NSLog(@"Mail Cancelled");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail Failed");
            break;
        default:
            break;
    }
}
[controller dismissModalViewControllerAnimated:YES];
}

我在控制台收到消息“已发送邮件”,但我喜欢我说,我从来没有收到我正在发送的电子邮件。

我已经浏览了苹果的文档,但找不到任何有帮助的东西,其他人可以帮助我吗?我做错了什么吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2012-01-04 22:42:13

请确保您是在设备上测试,电子邮件将不会通过模拟器发送。

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/8728615

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档