Retrieving email CC using Dataverse Web API

Using the Dataverse Web API you can pretty much run any CRUD (create, retrieve, update, delete) operation in the Dynamics 365 applications. However, you still find today some special cases like the one that I’m going to talk about in this article.

This special case is actually brought by the column type “PartyList”, which has always been a particular one in the platform.

https://docs.microsoft.com/en-us/powerapps/maker/data-platform/types-of-fields#different-types-of-lookups

Let’s say we have a simple email like this one:

Using the following GET request, we can retrieve the emails modified in the last hour, including the one above:

Notice how we have been able to retrieve the from and to columns using the corresponding complementary string columns sender and torecipients. What about the cc or the bcc columns? Well, unfortunately they don’t have a complementary string column that we can use. So, if you try to add the “cc” column or the lookup equivalent one like “_cc_value” in the select query, you would get an error like this:

{
    "error": {
        "code": "0x0",
        "message": "Could not find a property named '_cc_value' on type 'Microsoft.Dynamics.CRM.email'."
    }
}

Here is the first solution, you could use the relationship: email_activity_parties

Expand your query using this relationship and it will return all the activity parties involved in the email.

Notice you will need then to use the Activity Party attributes addressused and participationtypemask to retrieve the corresponding email address and the role that is playing the participant.

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/activityparty-entity#activity-party-types

An alternative to this solution is to use FetchXML. The Dataverse API also accepts a FetchXML query as a parameter which can be convenience in certain scenarios:

https://docs.microsoft.com/en-us/powerapps/developer/data-platform/webapi/retrieve-and-execute-predefined-queries#use-custom-fetchxml

2 thoughts on “Retrieving email CC using Dataverse Web API

  1. Hi Ramon, I have a question. In my project, we need access to the marketing data (e-mails). I have been searching for information and I can see that with Power Apps or Power Automate and Dataverse I can get the data, but is only data that I can access with Power BI. That means analytics … Do you know if I can access the table “emails#” from Marketing? I want to download data to Azure Data Lake and then export the data to other destinations.

Leave a Reply to Ramon Tebar Cancel reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s