Ejemplo n.º 1
0
        public Message GetMessage(string id)
        {
            var xml = GetResponse("<GetItem xmlns=\"" + URI_MSG + "\"><ItemShape><t:BaseShape>Default</t:BaseShape><t:IncludeMimeContent>false</t:IncludeMimeContent>" +
                                  "<t:AdditionalProperties><t:FieldURI FieldURI=\"item:Attachments\"/><t:FieldURI FieldURI=\"item:DateTimeReceived\"/><t:FieldURI FieldURI=\"item:ItemClass\"/></t:AdditionalProperties></ItemShape><ItemIds><t:ItemId Id=\"" + id + "\"/></ItemIds></GetItem>");
            var result = new Message()
            {
                Id               = id,
                ItemClass        = xml.SelectSingleNode("//t:ItemClass", _namespaceManager).InnerXml,
                Subject          = xml.SelectSingleNode("//t:Subject", _namespaceManager).InnerXml,
                Body             = xml.SelectSingleNode("//t:Body", _namespaceManager).InnerXml,
                BodyType         = xml.SelectSingleNode("//t:Body/@BodyType", _namespaceManager).Value,
                DateTimeReceived = DateTime.Parse(GetInnerXML(xml, "//t:DateTimeReceived", "1900.01.01")),
                From             = GetInnerXML(xml, "//t:From/t:Mailbox/t:EmailAddress")
            };

            if (result.BodyType == "HTML")
            {
                result.Body = XMLUtils.Decode(result.Body);
            }
            foreach (XmlNode f in xml.SelectNodes("//t:FileAttachment", _namespaceManager))
            {
                result.FileAttachments.Add(new AttachmentInfo()
                {
                    Id          = f.SelectSingleNode("t:AttachmentId/@Id", _namespaceManager).Value,
                    Name        = f.SelectSingleNode("t:Name", _namespaceManager).InnerXml,
                    ContentId   = GetInnerXML(f, "t:ContentId"),
                    ContentType = GetInnerXML(f, "t:ContentType"),
                    IsInline    = bool.Parse(f.SelectSingleNode("t:IsInline", _namespaceManager).InnerXml),
                    Size        = long.Parse(f.SelectSingleNode("t:Size", _namespaceManager).InnerXml)
                });
            }
            foreach (XmlNode f in xml.SelectNodes("//t:ToRecipients/t:Mailbox/t:EmailAddress", _namespaceManager))
            {
                result.To.Add(f.InnerXml);
            }
            foreach (XmlNode f in xml.SelectNodes("//t:CcRecipients/t:Mailbox/t:EmailAddress", _namespaceManager))
            {
                result.Cc.Add(f.InnerXml);
            }
            foreach (XmlNode f in xml.SelectNodes("//t:BccRecipients/t:Mailbox/t:EmailAddress", _namespaceManager))
            {
                result.Bcc.Add(f.InnerXml);
            }
            result.HasAttachments = result.FileAttachments.Count > 0;
            return(result);
        }
Ejemplo n.º 2
0
        public Task GetTask(string id)
        {
            var xml = GetResponse("<GetItem xmlns=\"" + URI_MSG + "\"><ItemShape><t:BaseShape>AllProperties</t:BaseShape><t:IncludeMimeContent>false</t:IncludeMimeContent>" +
                                  "<t:AdditionalProperties><t:ExtendedFieldURI PropertySetId=\"c11ff724-aa03-4555-9952-8fa248a11c3e\" PropertyName=\"TestProp\" PropertyType=\"String\" /> " +
                                  "<t:FieldURI FieldURI=\"item:Attachments\"/><t:FieldURI FieldURI=\"item:DateTimeReceived\"/><t:FieldURI FieldURI=\"item:ItemClass\"/></t:AdditionalProperties></ItemShape><ItemIds><t:ItemId Id=\"" + id + "\"/></ItemIds></GetItem>");
            var result = new Task()
            {
                Id               = id,
                ItemClass        = xml.SelectSingleNode("//t:ItemClass", _namespaceManager).InnerXml,
                Subject          = xml.SelectSingleNode("//t:Subject", _namespaceManager).InnerXml,
                Body             = xml.SelectSingleNode("//t:Body", _namespaceManager).InnerXml,
                BodyType         = xml.SelectSingleNode("//t:Body/@BodyType", _namespaceManager).Value,
                DateTimeReceived = DateTime.Parse(GetInnerXML(xml, "//t:DateTimeReceived", "1900.01.01")),
                Status           = xml.SelectSingleNode("//t:Status", _namespaceManager).InnerXml,
                HasAttachments   = bool.Parse(xml.SelectSingleNode("//t:HasAttachments", _namespaceManager).InnerXml)
            };

            if (result.BodyType == "HTML")
            {
                result.Body = XMLUtils.Decode(result.Body);
            }
            return(result);
        }