简体   繁体   English

使用 AlexaCRM php-crm-toolkit 在 Dynamics 365 中使用 php 创建电子邮件

[英]Create an email in Dynamics 365 with php using AlexaCRM php-crm-toolkit

I'm trying to create an email with php in Dynamics 365 by using the AlexaCRM php-crm toolkit after someone fills in the form on our website.在有人填写我们网站上的表格后,我尝试使用 AlexaCRM php-crm 工具包在 Dynamics 365 中使用 php 创建电子邮件。 The email also appears in Dynamics, but the from and to fields are empty.该电子邮件也出现在 Dynamics 中,但发件人和收件人字段为空。 The email itself and the subject are stored in Dynamics.电子邮件本身和主题存储在 Dynamics 中。

Does anyone had the same problem or does anyone knows what I'm doing wrong?有没有人有同样的问题,或者有没有人知道我做错了什么?

This is the code I'm using.这是我正在使用的代码。

<?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();

?>

Thanks for your help.谢谢你的帮助。 I created activityparties, but it still doesn"t write the email correctly to Dynamics.我创建了活动派对,但它仍然没有正确地将电子邮件写入 Dynamics。

I don't know how to combine the two parties.我不知道如何将两方结合起来。

This is my code:这是我的代码:

$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();

rather than而不是

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

you will have to use email_activity_parties as an array.您将不得不使用 email_activity_parties 作为数组。 I am not familair with PHP but something like below我不熟悉 PHP,但类似于下面的内容

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

This happens because To and From field is not text field rather it is Party list field .发生这种情况是因为 To 和 From 字段不是文本字段,而是派对列表字段

you cannot directly add/put email address, you will need to create object with it's type and email address.您不能直接添加/放置电子邮件地址,您需要使用它的类型和电子邮件地址创建对象。

Take a look at this blog, it has all the information you need. 看看这个博客,它有你需要的所有信息。

Below sample for To and from, but here these are users in system.下面是 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
        }]

Creating Email with unresolved emails (To field of email is not record in MS CRM).使用未解析的电子邮件创建电子邮件(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
        }
        ]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用php-crm-toolkit在Microsoft Dynamics Online CRM中创建案例或事件 - How To Create a case Or Incident In Microsoft Dynamics Online CRM using php-crm-toolkit 在PHP中使用API​​在Dynamics CRM中创建事件 - Create incident in dynamics crm using api in php 尝试使用 PHP 中的 API 在 Dynamics CRM 中创建潜在客户 - Trying to create lead in Dynamics CRM using API in PHP 如何使用 php 集成 Microsoft Dynamics 365 CRM Common Data Service? - How to integrate Microsoft Dynamics 365 CRM Common Data Service using php? 将选择列表值在线发送到 Dynamics crm 以使用soap php 创建潜在客户 - Send picklist value to Dynamics crm online to create lead using soap php 如何使用 PHP 集成 Dynamics CRM 2015 内部部署 API 并创建潜在客户 - How to integrate Dynamics CRM 2015 on-premise API using PHP and create leads 通过PHP CURL在Microsoft Dynamics Nav 365中创建销售线索 - Create a lead in Microsoft Dynamics Nav 365, from PHP CURL Microsoft Dynamics CRM和PHP / JSON - Microsoft Dynamics CRM and PHP/JSON 如何使用PHP在Dynamics 365中添加新联系人 - How to Add a New Contact in Dynamics 365 using PHP 使用SOAP客户端从PHP在Dynamics CRM上创建用户帐户 - Creating a User Account on Dynamics CRM from PHP using SOAP client
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM