Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Answered

How to get From and To from email entity using fetch XML using c#

(0) ShareShare
ReportReport
Posted on by 150

Hello Everyone,

                     How to get  FROM  and TO value using c#, i have done the following code but it not retrieve FROM , TO from.  thanks in advance.

var resultEmail = service.RetrieveMultiple(
new FetchExpression(
string.Format("<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" +
" <entity name='email'>" +
" <attribute name='subject' />" +
" <attribute name='regardingobjectid' />" +
" <attribute name='from' />" +
" <attribute name='to' />" +
" <attribute name='prioritycode' />" +
" <attribute name='statuscode' />" +
" <attribute name='modifiedon' />" +
" <attribute name='activityid' />" +
" <attribute name='description' />" +
" <order attribute='subject' descending='false' />" +
"<filter type='and'>" +
"<condition attribute='regardingobjectid' operator='eq' value='{0}' />" +
" </filter>" +
" </entity>" +
"</fetch>", CaseId)));
if (resultEmail.Entities.Count > 0)
{
foreach (var attributenameEmail in resultEmail.Entities)
{

Description = attributenameEmail.Attributes["description"].ToString();
From = attributenameEmail.Attributes["from"].ToString();
To = attributenameEmail.Attributes["to"].ToString();
Subject = attributenameEmail.Attributes["subject"].ToString();

}
}

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to get From and To from email entity using fetch XML using c#

    You can use something like:

    var toFieldValue = attributenameEmail.GetAttributeValue<EntityCollection>("to");

    var fromFieldValue = attributenameEmail.GetAttributeValue<EntityCollection>("from");

  • Razim Khan Profile Picture
    150 on at
    RE: How to get From and To from email entity using fetch XML using c#

    yes , but how to get the value of TO and FROM in c# ?

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at
    RE: How to get From and To from email entity using fetch XML using c#

    Razim,

    "from" and "to" are EntityCollection actually.

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at
    RE: How to get From and To from email entity using fetch XML using c#

    Hi, 

    You can find this info in ActivityParty Entity. Please refer to the doc:

     https://docs.microsoft.com/en-us/dynamics365/customerengagement/on-premises/developer/activityparty-entity

    Also check this thread: 

    community.dynamics.com/.../591064

  • Daniel Schneider Profile Picture
    172 on at
    RE: How to get From and To from email entity using fetch XML using c#

    Hi,

    get you values of the other attributes or nothing? CaseId is a string or typeof Guid?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 95

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans