从 iOS 设备发送电子邮件时出现问题?

Issue in sending email from iOS device?

我想使用 iOS.I 从我的 iOS 设备以编程方式发送电子邮件,我正在使用以下代码发送电子邮件,但我不知道从哪里输入 field.From邮件将发送到哪个电子邮件 ID?

在iOS

中发送电子邮件的代码
// Email Subject
    if(![MFMailComposeViewController canSendMail])
    {
        UIAlertView *warningAlert = [[UIAlertView alloc] initWithTitle:@"Error" message:@"Your device doesn't support Email!" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil];
        [warningAlert show];
        return;

    }
    NSString *emailTitle = @"Test Email";
    // Email Content
    NSString *messageBody = @"iOS programming is so fun!";
    // To address
    NSArray *toRecipents = [NSArray arrayWithObject:@"support@appcoda.com"];

    MFMailComposeViewController *mc = [[MFMailComposeViewController alloc] init];
    mc.mailComposeDelegate = self;
    [mc setSubject:emailTitle];
    [mc setMessageBody:messageBody isHTML:NO];
    [mc setToRecipients:toRecipents];

    // Present mail view controller on screen
    [self presentViewController:mc animated:YES completion:NULL];

不能在使用MFMailComposeViewController时实际设置From字段。实际发生的是 From 字段将默认为用户在设置中指定用作设备上默认电子邮件帐户的任何电子邮件帐户。

补充一下,使用内置 MFMailComposeViewController class 不能做的另一件事是静默发送电子邮件,没有全屏显示 "Compose email" 视图。

在我的应用中,我将电子邮件详细信息(收件人地址、正文等)发送到我应用的 WCF Web 服务,然后改为发送电子邮件。

当然,如果这样做,您可以选择您希望使用的发件人地址。