How to – Send an email using AddressUsed attribute of ActivityParty entity in Dynamics 365

When it comes to sending an email in Dynamics 365 / CE / CRM, we specify the entity’s record (with email enabled) in to, cc and bcc field of the email activity entity, and then the email address attribute of that particular record is used.

We can enable email for a custom entity also.

What if we have multiple email address fields specified for a custom entity?

The field which was created first will be used.

Check the below blog post –

What about entity like contact and account which have email, email address 2 and email address 3 fields?

If we trying sending an email to the above contact record, which has email address fields as blank programmatically we will get the below error

“Could not find the email address for the recipient of type ‘Contact’ with ID…”

What if we only have the email address 3 field having email id specified and the other 2 email field are blank?

This time our code will run without error, and CRM will pick up the email id specified in the email address 3 field. It will first check for email, then email address 2, and then finally email address 3 field. This happens only in the case of out of the box entity like contact and account.

What if we want to send an email to an email id not specified in the record?

Well in that case AddressUsed attribute of Activity Party can be used as shown below –

On running the above code, we can see the email specified in the addressused field being used

Understand more about activity party entity

The helpful post

Hope it helps..

string ConnectionString = "AuthType = OAuth; " +
"Username = userid;" +
"Password = pwd; " +
"Url =;" +
"AppId=51f81489-12ee-4a9e-aaae-a2591f45987d;" +
"RedirectUri=app://58145B91-0C36-4500-8554-080854F2AC97;" +

            CrmServiceClient svc = new CrmServiceClient(ConnectionString);

            if (svc.IsReady)
                // guid of the contact record 
                Guid contactID = new Guid("0bd90832-bb52-eb11-bb23-000d3a5696d2");

                // initializing activity party entity
                Entity fromAP = new Entity("activityparty");
                Entity toAP = new Entity("activityparty");
                fromAP["partyid"] = new EntityReference("systemuser", new Guid("7de293e1-8352-eb11-bb23-000d3a569919"));
                toAP["partyid"] = new EntityReference("contact", contactID);

                // using the addressused attribute
                toAP["addressused"] = "";

                // create email record
                Entity email = new Entity("email");
                email["from"] = new Entity[] { fromAP };
                email["to"] = new Entity[] { toAP };
                email["regardingobjectid"] = new EntityReference("contact", contactID);
                email["subject"] = "Sample Subject";
                email["description"] = "This is sample description.";             
                Guid emailId = svc.Create(email);

                // Send email
                SendEmailRequest sendEmailRequest = new SendEmailRequest
                    EmailId = emailId,                   
                    IssueSend = true

                SendEmailResponse sendEmailResponse = (SendEmailResponse)svc.Execute(sendEmailRequest);


Author: Nishant Rana

I love working in and sharing everything about Microsoft.NET technology !

2 thoughts on “How to – Send an email using AddressUsed attribute of ActivityParty entity in Dynamics 365”

  1. Hi,

    Why do we need below line of code if we are only setting Email address which are unresolved.
    toAP[“partyid”] = new EntityReference(“contact”, contactID);

    It does not make sense.

    I have tried without this line of code and it works fine.


    Liked by 1 person

Please share your thoughts

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

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

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

My Trial

It is my experience timeline.


Sharing my knowledge and experience about the Microsoft Power Platform.

Arpit Power Guide

a guide to powering up community

Welcome to the Blog & Website of Paul Andrew

Technical Leadership Centred Around the Microsoft Data Platform

Deriving Dynamics 365

Deriving Solutions and features on Power Platform/Dynamics 365

The CRM Ninja

Thoughts & musings from a Dynamics 365 Ninja!

D CRM Explorer

Learn about Microsoft Dynamics CRM Power Platform customization and implementation and other cool stuffs

Stroke // Jonas Rapp

I know pre-stroke. I will improve who I was.

Power Melange

Power Melange By Shalinee

Clavin's Blog

Power Automate - Power Apps - SharePoint Online - Azure - Nintex - K2 - Artificial Intelligence

Sat Sangha Salon

An Inquiry in Being

The Indoencers

The Influencers & Influences of Indian Music

Monika Halan's blog

Hand's-free money management

D365 Demystified

A closer look at Microsoft Dynamics 365.

Microsoft Mate (msftmate) - Andrew Rogers

Experienced consultant primarily focused on Microsoft Dynamics 365 and the Power Platform


Specific topics by Django Lohn on the whole Microsoft365 Stack

Manmit Rahevar's Blog

One Stop Destination for Microsoft Technology Solutions


Naturally Curious

Brian Illand

Power Platform and Dynamics 365

Steve Mordue MVP

A Microsoft Business Applications MVP

Subwoofer 101

Bass defines your home theater

SQLTwins by Nakul Vachhrajani

SQL Server tips and experiences dedicated to my twin daughters.

Everything D365

Discovering Azure DevOps and D365 Business Applications

Tech Wizard

Lets do IT Spells

XRM Tricks (Power Platform & Dynamics CRM )

Power Platform & Dynamics CRM


Mail to for queries and suggestions

Giving back to the community what I have learned

xrm CRM Dynamics

Dynamics CRM Technical & Functional Info

Dynamics 365 Blogs - Explained in unique way

Sometimes you need to look at things from different perspective.

CRM Keeper

Dynamics 365 Customer Engagement, CRM, Microsoft CRM, Dynamics CRM


Step into the world of a Dynamics 365 Consultant

Dianamics PCF Lady

Diana & Dynamics 365 & Power Platform

%d bloggers like this: