【问题标题】:Create an email in Dynamics 365 with php using AlexaCRM php-crm-toolkit使用 AlexaCRM php-crm-toolkit 在 Dynamics 365 中使用 php 创建电子邮件
【发布时间】:2020-09-28 17:40:26
【问题描述】:

在有人填写我们网站上的表格后,我正在尝试使用 AlexaCRM php-crm 工具包在 Dynamics 365 中使用 php 创建电子邮件。 电子邮件也出现在 Dynamics 中,但 from 和 to 字段为空。电子邮件本身和主题都存储在 Dynamics 中。

有没有人遇到同样的问题或者有谁知道我做错了什么?

这是我正在使用的代码。

<?php
require_once '../vendor/autoload.php';

use AlexaCRM\CRMToolkit\Client as OrganizationService;
use AlexaCRM\CRMToolkit\Settings;
use AlexaCRM\CRMToolkit\Client;
use AlexaCRM\CRMToolkit\Entity\MetadataCollection;
use AlexaCRM\CRMToolkit\Entity\EntityReference;

$options = [
    'serverUrl' => 'xxx.dynamics.com',
    'username' => 'xxx@xxx.com',
    'password' => 'xxxxxx',
    'authMode' => 'OnlineFederation',
];

$serviceSettings = new Settings( $options );
$service = new OrganizationService( $serviceSettings );

$email = $service->entity( 'email' );
$email->subject = 'TEST SUBJECT';
$email->description = 'TEST EMAIL';
$email->sender = 'Sender Name';
$email->from = 'test@gmail.com';
$email->to = 'Our Company';
$email->torecipients = 'test@ourcompany.com';
$emailId = $email->create();

?>

【问题讨论】:

    标签: php email dynamics-365


    【解决方案1】:

    感谢您的帮助。 我创建了活动派对,但它仍然无法将电子邮件正确写入 Dynamics。

    我不知道如何将两者结合起来。

    这是我的代码:

    $to = $service->entity( 'activityparty' );
    $to->partyid = new EntityReference( 'systemuser', ''.$guid_stassen.'');
    
    $from = $service->entity( 'activityparty' );
    $from->partyid = new EntityReference( 'contact', ''.$guid.'');
    
    $email = $service->entity( 'email' );
    $email->subject = 'TEST SUBJECT';
    $email->description = 'TEST EMAIL';
    $email->from = ''.$from.'';
    $email->to = ''.$to.'';
    $emailId = $email->create();
    

    而不是

    $email->from = ''.$from.'';
    $email->to = ''.$to.''; 
    

    您必须使用 email_activity_parties 作为数组。我不熟悉 PHP,但如下所示

    $email->email_activity_parties=[
            {
                "partyid_systemuser@odata.bind" : "/systemusers(CED2E02D-188E-4AA8-B6E2-D746E9B370C1)",
                "participationtypemask" : 1
            },
             {
               "addressused":"vvyas@cloudfronts.com",
                "participationtypemask" : 2
            }
            ];
    

    发生这种情况是因为 To 和 From 字段不是文本字段,而是 Party list field

    您不能直接添加/放置电子邮件地址,您需要使用其类型和电子邮件地址创建对象。

    Take a look at this blog, it has all the information you need.

    下面是 To 和 from 的示例,但这里是系统中的用户。

    "email_activity_parties" : [
            {
                "partyid_systemuser@odata.bind" : "/systemusers(CED2E02D-188E-4AA8-B6E2-D746E9B370C1)",
                "participationtypemask" : 1  ///From Email
            },
            {
                "partyid_account@odata.bind" : "/accounts(69C38067-EDB7-E811-A961-000D3A363C81)",
                "participationtypemask" : 2  ///To Email
            }]
    

    使用未解决的电子邮件创建电子邮件(MS CRM 中不记录电子邮件的收件人字段)。

    "email_activity_parties" : [
            {
                "partyid_systemuser@odata.bind" : "/systemusers(CED2E02D-188E-4AA8-B6E2-D746E9B370C1)",
                "participationtypemask" : 1 ///From Email
            },
             {
               "addressused":"vvyas@cloudfronts.com",
                "participationtypemask" : 2 ///To Email
            }
            ]
    

    【讨论】:

      猜你喜欢
      • 2019-07-04
      • 1970-01-01
      • 1970-01-01
      • 2013-07-26
      • 2023-03-14
      • 1970-01-01
      • 2016-11-29
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多