如何在salesforce iOS中访问win的所有者电子邮件

时间:2014-11-20 05:41:41

标签: ios email salesforce

我们说我有一个名为SalesSample的应用程序。它使用salesforce,我的一个队友赢得了salesforce的交易,但没有使用SalesSample应用程序。在SalesSample应用程序中,即使他们不使用SalesSample,我也可以通过电子邮件向交易获胜者发送电子邮件吗? salesforce api是否允许我们访问赢得交易的人的电子邮件? 如果可能,有人可以告诉我如何执行此操作的步骤。

1 个答案:

答案 0 :(得分:0)

终于找到了解决方案。我只是查询机会的记录,检查拥有它的用户。

NSString *theRequest = [NSString stringWithFormat:@"SELECT Owner.Email FROM Opportunity "];
SFRestRequest *request = [[SFRestAPI sharedInstance] requestForQuery:theRequest];
[[SFRestAPI sharedInstance] send:request delegate:self];

然后使用MessageUI.framework:

使用电子邮件
- (void)showEmail:(id)sender {
NSString  *emailTitle = @"Email Subject";
NSString  *messageBody = @"Email Content";
NSArray  *toRecipents = [NSArray  arrayWithObject:@"Returned Email from query here"];

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

[self presentViewController:mc animated:YES completion:NULL];
}

- (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];
} else {
    switch (result)
    {
        case MFMailComposeResultCancelled:
            NSLog(@"Mail cancelled");
            break;
        case MFMailComposeResultSaved:
            NSLog(@"Mail saved");
            break;
        case MFMailComposeResultSent:
            NSLog(@"Mail sent");
            break;
        case MFMailComposeResultFailed:
            NSLog(@"Mail sent failure: %@", [error localizedDescription]);
            break;
        default:
            break;
    }
}
// Close the Mail Interface
[self dismissViewControllerAnimated:YES completion:NULL];
}