web
You’re offline. This is a read only version of the page.
close
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();

}
}

I have the same question (0)
  • Daniel Schneider Profile Picture
    172 on at

    Hi,

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

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at

    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

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Razim,

    "from" and "to" are EntityCollection actually.

  • Razim Khan Profile Picture
    150 on at

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

  • Verified answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    You can use something like:

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

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

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 70 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 43 Most Valuable Professional

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans