【问题标题】:MFMailComposeViewController in iphone appiPhone应用程序中的MFMailComposeViewController
【发布时间】:2023-03-16 19:06:01
【问题描述】:

大家好

我们可以使用“MFMailComposeViewController”而不使用“presentModalViewController”吗,我的意思是我需要发送电子邮件而不导航到该邮件撰写器页面

我用以下代码做了一个测试项目

- (IBAction)buttonPressed {
    arrRecipients = [[NSMutableArray alloc]init];
    [arrRecipients addObject:@"xxxxxxx@gmail.com"];


    MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
    mailController.mailComposeDelegate = self;
    [mailController setSubject:@"Ravikiran test mail"];
    [mailController setToRecipients:arrRecipients];

    [mailController setMessageBody:@"this is my test app" isHTML:YES];
    [self presentModalViewController:mailController animated:YES];
    [mailController release];
}

它正在发送邮件,但它正在导航到邮件编写器页面,然后它正在发送,但我只需单击按钮即可发送邮件

【问题讨论】:

    标签: iphone objective-c email sendmail


    【解决方案1】:

    不,您不能在没有用户交互的情况下使用MFMailComposeViewController 发送电子邮件。可能有 3rd 方库可以让您执行此操作,但 iOS SDK 不允许您这样做。

    另外,您正在泄漏 arrRecipients 数组。

    【讨论】:

    • 哦,我明白了,还有其他方法可以满足我的要求吗?
    【解决方案2】:

    满足您需求的最佳方式是拥有一个将数据发送到电子邮件 ID 的网络服务。 在发送邮件之前以某种方式通知用户总是好的。

    谢谢!

    【讨论】:

      猜你喜欢
      • 2011-07-17
      • 2010-12-14
      • 2010-12-12
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-11-04
      相关资源
      最近更新 更多