首页 文章

发送包含用户输入数据的电子邮件

提问于
浏览
0

我正在为一个企业开发一个应用程序 . 这个应用程序本质上是一个产品订单应用程序,从数据库文件中获取产品 . 选择文件后,它将移动到包含数量,长度,颜色等选项的页面 . 然后,如果确认购买,则会转到另一页面以填写用户信息 .

有没有办法将用户从两个页面输入的详细信息打印到电子邮件并将该电子邮件发送到特定的帐单邮寄地址?对于用户来说,只需按下确认按钮,但在后台它会发送一封包含所有这些信息的电子邮件 . 我发现不同的论坛正在谈论来自iPhone应用程序的电子邮件,但似乎没有一个像我需要的那样工作 .

2 回答

  • 0

    您可以向邮件编辑器添加任何文本,如下所示:

    MFMailComposeViewController *mailController = [[MFMailComposeViewController alloc] init];
    [mailController setMessageBody:[NSString stringWithFormat:@"User %@ ordered %d of %@ at a price of %f",
                                    orderCustomer,
                                    orderQuantity,
                                    orderItem,
                                    orderPrice]
                            isHTML:NO];
    [self presentModalViewController:mailController animated:YES];
    [mailController release];
    

    如您所见,如果希望您的订单格式正确,您还可以将html插入邮件消息正文中 .

  • 1

    是的 . 捕获用户输入的一种简单方法是使用屏幕截图 . 然后将其附加到电子邮件中 . 您可以将屏幕渲染为pdf或图像格式 .

    就像是:

    //draw main window in image context
    UIWindow *window=[[[UIApplication sharedApplication] windows] objectAtIndex:0];
    [[window layer] renderInContext:context];
    //convert to UIImage
    UIImage *image = UIGraphicsGetImageFromCurrentImageContext();
    //clean up
    UIGraphicsEndImageContext();
    //return
    return image;
    

    至于在后台发送电子邮件,您需要使用第三方库 . MFMailComposeViewController可用于从iOS发送电子邮件,但需要用户确认电子邮件对话框 .

相关问题