How do you retrieve party list data (To, From etc) along with the rest of an email record via .Net & CRM 4 RRS feed

  • Question

  • Hi,

    I think i may be getting myself confused with this, but how do you retrieve the To & From fields along with the rest of an Email record? So for example, I have some fetch xml (although a Query Expression solution would also be fine):

            string fetchXml = @"
                                <fetch mapping='logical'>
                                    <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'/>
                                        <order descending='false' attribute='subject'/>
                                        <link-entity name='contact' alias='ag' to='regardingobjectid' from='contactid'>
                                            <filter type='and'> 
                                                <condition attribute='examplecondition' value='1' operator='eq'/> 
                                                <condition attribute='anotherexamplecondition' value='5' operator='eq'/>
            XDocument document = crmService.ToXDocument(contactEmailfetchXml);
            var results = document.Root.Elements("result").Select(e =>
                new Email
                        ActivityId = e.Element("activityid").ToGuid(),
                        Subject = e.Element("subject").Val(),
                        //From = e.Element("from").Val(),
                        //To = e.Element("to").Val(),
                        //CC = e.Element("cc").Val(),
                        PriorityCode = e.Element("prioritycode").Val()

    And the 'Val' extension method is just:

        public static string Val(this XElement element)
            return element != null
                ? element.Value
                : String.Empty;

    Any help would be really appreciated.


    • Edited by dizzy1979 Monday, February 3, 2014 1:14 PM
    Monday, February 3, 2014 1:13 PM