无法阅读“业余爱好,地点和学校”使用EWS从Office365获取联系人项目的属性 [英] Unable to Read "Hobby, Location and School" Properties of Contact Item from Office365 using EWS

查看:94
本文介绍了无法阅读“业余爱好,地点和学校”使用EWS从Office365获取联系人项目的属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用"Microsoft.Exchange.WebServices.dll"阅读Office365联系人。无法阅读  "爱好,地点和学校"联系人的属性。

I'm using "Microsoft.Exchange.WebServices.dll" to read Office365 contacts . Unable to read "Hobby, Location and School" Properties of contact.

任何人都可以帮助我。

Thanx和问候,

Tirupati 

推荐答案

最可靠的方法是使用扩展属性,因为其中一些不是强类型属性,例如

The most reliable way would be to use the Extended properties as some of these aren't Strongly typed properties eg

            ExtendedPropertyDefinition Hobby = new ExtendedPropertyDefinition(0x3A43,MapiPropertyType.String);
            ExtendedPropertyDefinition School = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Address, 0x80E9,MapiPropertyType.String);
            ExtendedPropertyDefinition Location = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, 0x8208,MapiPropertyType.String);
            PropertySet ContactProp = new PropertySet(BasePropertySet.FirstClassProperties) {Hobby,School,Location};
            
            FindItemsResults<Item> fiResults = null;
            ItemView ivItemView = new ItemView(1000);
            ivItemView.PropertySet = ContactProp;
            do
            {
                fiResults = service.FindItems(WellKnownFolderName.Contacts, ivItemView);
                foreach (Item itItem in fiResults.Items) 
                {
                    Console.WriteLine(itItem.Subject);
                    Object HobbyValue = null;
                    if (itItem.TryGetProperty(Hobby, out HobbyValue)) 
                    {
                        Console.WriteLine(HobbyValue);
                    }
                    Object SchoolValue = null;
                    if (itItem.TryGetProperty(School, out SchoolValue))
                    {
                        Console.WriteLine(SchoolValue);
                    }
                    Object LocationValue = null;
                    if (itItem.TryGetProperty(Location, out LocationValue))
                    {
                        Console.WriteLine(LocationValue);
                    }
                }
                ivItemView.Offset += fiResults.Items.Count;

            } while (fiResults.MoreAvailable

干杯zh
Glen

Cheers
Glen


这篇关于无法阅读“业余爱好,地点和学校”使用EWS从Office365获取联系人项目的属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆