Ejemplo n.º 1
0
        private object GetMailItemUserProperty(Outlook.UserProperties mailUserProperties)
        {
            object result = null;

            //Outlook.UserProperties mailUserProperties = mailItem.UserProperties;
            Outlook.UserProperty propJobMetaData = mailUserProperties.Find("JobMetaData");
            if (propJobMetaData != null)
            {
                try
                {
                    IList <Recruiter.JobItem> list = JsonConvert.DeserializeObject <IList <Recruiter.JobItem> >(propJobMetaData.Value);
                    //if (list.Count == 0)
                    result = list;
                    //this.jobListTaskPane.AddJobsInfo( list );
                }
                catch// (Exception ex)
                {
                    try
                    {
                        result = JsonConvert.DeserializeObject <ILetter>(propJobMetaData.Value);
                    }
                    catch// (Exception ex0)
                    {
                        //result = JsonConvert.DeserializeObject<NonJobLetter>( propJobMetaData.Value )
                    }
                    //
                }
            }

            return(result);
        }
        public Type GetUserProperty <Type>(string name)
        {
            using (ComRelease com = new ComRelease())
            {
                NSOutlook.UserProperties userProperties = com.Add(GetUserProperties());
                NSOutlook.UserProperty   prop           = com.Add(userProperties.Find(name, true));
                if (prop == null)
                {
                    return(default(Type));
                }

                if (typeof(Type).IsEnum)
                {
                    return(typeof(Type).GetEnumValues().GetValue(prop.Value));
                }
                return(prop.Value);
            }
        }
        public void SetUserProperty <Type>(string name, Type value)
        {
            using (ComRelease com = new ComRelease())
            {
                NSOutlook.UserProperties userProperties = com.Add(GetUserProperties());
                NSOutlook.UserProperty   prop           = com.Add(userProperties.Find(name, true));
                if (prop == null)
                {
                    prop = userProperties.Add(name, Mapping.OutlookPropertyType <Type>());
                }

                if (typeof(Type).IsEnum)
                {
                    int i = Array.FindIndex(typeof(Type).GetEnumNames(), n => n.Equals(value.ToString()));
                    prop.Value = typeof(Type).GetEnumValues().GetValue(i);
                }
                else
                {
                    prop.Value = value;
                }
            }
        }