$to = "to@gmail.com";
$subject = "Subject Of The Mail";
$message = "Hi there,<br/><br/>This is my message.<br><br>";
$headers = "From: From-Name<from@gmail.com>";
// boundary
$semi_rand = md5(time());
$mime_boundary = "==Multipart_Boundary_x{$semi_rand}x";
// headers for attachment
$headers .= "\nMIME-Version: 1.0\n" . "Content-Type: multipart/mixed;\n" . " boundary=\"{$mime_boundary}\"";
// multipart boundary
$message = "This is a multi-part message in MIME format.\n\n" . "--{$mime_boundary}\n" . "Content-Type: text/html; charset=ISO-8859-1\"\n" . "Content-Transfer-Encoding: 7bit\n\n" . $message . "\n\n";
$message .= "--{$mime_boundary}\n";
$filepath = 'uploads/'.$_FILES['image']['name'];
move_uploaded_file($_FILES['image']['tmp_name'], $filepath); //upload the file
$filename = $_FILES['image']['name'];
$file = fopen($filepath, "rb");
$data = fread($file, filesize($filepath));
fclose($file);
$data = chunk_split(base64_encode($data));
$message .= "Content-Type: {\"application/octet-stream\"};\n" . " name=\"$filename\"\n" .
"Content-Disposition: attachment;\n" . " filename=\"$filename\"\n" .
"Content-Transfer-Encoding: base64\n\n" . $data . "\n\n";
$message .= "--{$mime_boundary}\n";
mail($to, $subject, $message, $headers);
Для получения искомых сущностей вам, возможно, повезет больше, если вы сделаете $expand
для ManyToOneRelationships
вместо Attributes
и получите значение ReferencedEntity
.
Примерно так должно работать:
.../api/data/v9.1/EntityDefinitions(LogicalName='account')
?$select=LogicalName
&$expand=ManyToOneRelationships($select=ReferencingAttribute,ReferencedEntity)
Подмножество результатов:
< blockquote>{"@ odata.context": " https://myOrg.api.crm.dynamics.com/api/data/v9.1/ $ metadata # EntityDefinitions (LogicalName, ManyToOneRelationships (ReferencingAttribute, ReferencedEntity)) / $ сущность " "LogicalName": "счет", "MetadataId": "70816501-edb9-4740-a16c-6a5efbc05d84", "ManyToOneRelationships": [{ "ReferencingAttribute": "msdyn_accountkpiid"," ReferencedEntity ":" msdyn_accountkpiitem " "MetadataId": "2a712c96-09b1-e811-a842-000d3a33bdbd"}, { "ReferencingAttribute": "preferredequipmentid", "ReferencedEntity": "оборудование", "MetadataId":" b4b462b5-ee78- 467d-a97a-45264d234816 "}, {" ReferencingAttribute ":" primarycontactid», "ReferencedEntity": "контакт", "MetadataId": "410707b1-9554-4cd9-8437-6608b1802904"}, { "ReferencingAttribute": "masterid" "ReferencedEntity": "счет", "MetadataId": "51fa4af7-93d0-4f06-8949-38a0036ddc64"}, { "ReferencingAttribute": "preferredsystemuserid",» ReferencedEntity ":" systemuser " "MetadataId": "a6b48e23-Fada-4b7f-8655-530bba050765"}, { "ReferencingAttribute": "createdbyexternalparty", "ReferencedEntity": "externalparty", "MetadataId":" 9967fe7d-84ee- 4a26-9ad7-a8fdbdfa2316 "}, {" ReferencingAttribute ":" ModifiedBy», "ReferencedEntity": "systemuser", "MetadataId": "8be02a9d-0776-4c76-b35f-1c92dd791d9e"}, { "ReferencingAttribute": "parentaccountid" , "ReferencedEntity": "счет", "MetadataId": "57511732-b553-4cfb-bcf2-d280f9f8c6f1"}, { "ReferencingAttribute": "entityimageid", "ReferencedEntity": "imagedescriptor", "MetadataId": "5b4942d5- 1fcd-49ca-91c0-2737f5f104f3 "},
blockquote> Также для справки я попытался сделать $expand
для атрибутов и целей:
../api/data/v9.1/EntityDefinitions(LogicalName='account')?$select=LogicalName&$expand=Attributes($filter=AttributeType+eq+Microsoft.Dynamics.CRM.AttributeTypeCode%27Lookup%27&$expand=Targets)
«Опция запроса« $ expand »была указана более одного раза, но она должна быть указана не более одного раза.»
blockquote>