Example #1
0
        private static T ReadObjectFromMessage(MapiMessage mapiMessage, bool throwOnDeserializationError)
        {
            T result;

            using (MapiStream mapiStream = mapiMessage.OpenStream(PropTag.Body, OpenPropertyFlags.BestAccess))
            {
                result = MoveObjectInfo <T> .DeserializeFromStream(mapiStream, throwOnDeserializationError);
            }
            return(result);
        }
Example #2
0
        public List <T> ReadObjectChunks(ReadObjectFlags flags)
        {
            if ((flags & ReadObjectFlags.Refresh) != ReadObjectFlags.None)
            {
                this.message.Dispose();
                this.message = null;
            }
            if (this.message == null && !this.OpenMessage())
            {
                return(null);
            }
            List <T> list = new List <T>();
            T        t;

            if ((flags & ReadObjectFlags.LastChunkOnly) == ReadObjectFlags.None)
            {
                using (MapiTable attachmentTable = this.message.GetAttachmentTable())
                {
                    if (attachmentTable != null)
                    {
                        PropValue[][] array = attachmentTable.QueryAllRows(null, MoveObjectInfo <T> .AttachmentTagsToLoad);
                        foreach (PropValue[] array3 in array)
                        {
                            int @int = array3[0].GetInt();
                            using (MapiAttach mapiAttach = this.message.OpenAttach(@int))
                            {
                                using (MapiStream mapiStream = mapiAttach.OpenStream(PropTag.AttachDataBin, OpenPropertyFlags.BestAccess))
                                {
                                    t = MoveObjectInfo <T> .DeserializeFromStream(mapiStream, (flags & ReadObjectFlags.DontThrowOnCorruptData) == ReadObjectFlags.None);
                                }
                                if (t != null)
                                {
                                    list.Add(t);
                                }
                            }
                        }
                    }
                }
            }
            t = MoveObjectInfo <T> .ReadObjectFromMessage(this.message, (flags & ReadObjectFlags.DontThrowOnCorruptData) == ReadObjectFlags.None);

            if (t != null)
            {
                list.Add(t);
            }
            if (list.Count <= 0)
            {
                return(null);
            }
            return(list);
        }