Код: Выделить всё
// Establish connection
$service = new DynamicsCRM2011_Connector($serverUrl,$organizationUniqueName, $username, $password);
// Create email message entity
$emailMessage = new DynamicsCRM2011_Entity('email');
$emailMessage->set('subject', 'Test Email');
$emailMessage->set('description', 'This is a test email message.');
// Set sender
$from = new DynamicsCRM2011_EntityReference('systemuser');
$from->id = '{sender_systemuser_id}'; // Replace with actual sender system user ID
$emailMessage->set('from', $from);
// Set To (PartyList)
$toPartyList = array();
// Add contact to the PartyList
$contactRef = new DynamicsCRM2011_EntityReference('contact');
$contactRef->id = '{recipient_contact_id}'; // Replace with actual recipient contact ID
$toPartyList[] = $contactRef;
// Add system user to the PartyList
$userRef = new DynamicsCRM2011_EntityReference('systemuser');
$userRef->id = '{recipient_systemuser_id}'; // Replace with actual recipient system user ID
$toPartyList[] = $userRef;
// Set To field
$emailMessage->set('to', $toPartyList);
// Save email message
$emailMessageId = $service->create($emailMessage);
if ($emailMessageId) {
echo "Email message created successfully with ID: $emailMessageId";
} else {
echo "Failed to create email message.";
}
Подробнее здесь: https://stackoverflow.com/questions/784 ... -connector