none
How to read message from HealthVault account using HealthVault SDK

    Question

  • I was trying to read email messages from HealthVault PPE account and I was under the impression that the following code will give me a list of messages but even if I have messages in my account I am not able to read them using the code.

    I am able to read weight data using the sample which is similar code

               HealthClientAuthorizedConnection connection =
                    HealthClientApplication.CreateAuthorizedConnection(PersonId);

                HealthRecordAccessor accessor = new HealthRecordAccessor(connection, RecordId);

                HealthRecordSearcher searcher = accessor.CreateSearcher();
                HealthRecordFilter filter = new HealthRecordFilter(Message.TypeId);
                
                filter.View.Sections = HealthRecordItemSections.All | HealthRecordItemSections.Xml;
                searcher.Filters.Add(filter);
               
                HealthRecordItemCollection items = searcher.GetMatchingItems()[0];

    Can somebody please help me with this?

    Thanks!

    Wednesday, December 11, 2013 6:19 PM

Answers

  • I was able to get to the messages via this code:

            HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher();
            HealthRecordFilter filter = new HealthRecordFilter(Message.TypeId);
            filter.View.Sections = HealthRecordItemSections.All | HealthRecordItemSections.Xml;
            searcher.Filters.Add(filter);
            HealthRecordItemCollection items = searcher.GetMatchingItems()[0];
            foreach (Message msg in items)
            {
                string sub = msg.Subject;
                // retrieve each message here as msg.<whatever you are interested in>
            }

    Friday, December 13, 2013 7:02 PM

All replies

  • Do you get an error?

    Wednesday, December 11, 2013 8:12 PM
  • No error, items did not have anything in it even though I know I have messages in the account.
    Wednesday, December 11, 2013 8:24 PM
  • I was able to get to the messages via this code:

            HealthRecordSearcher searcher = PersonInfo.SelectedRecord.CreateSearcher();
            HealthRecordFilter filter = new HealthRecordFilter(Message.TypeId);
            filter.View.Sections = HealthRecordItemSections.All | HealthRecordItemSections.Xml;
            searcher.Filters.Add(filter);
            HealthRecordItemCollection items = searcher.GetMatchingItems()[0];
            foreach (Message msg in items)
            {
                string sub = msg.Subject;
                // retrieve each message here as msg.<whatever you are interested in>
            }

    Friday, December 13, 2013 7:02 PM