Ejemplo n.º 1
0
        /// <summary>
        /// Gets an attachment from an item.
        /// </summary>
        /// <param name="bodyType">Represents the format of the body text in a response.</param>
        /// <param name="includeMimeContent">Indicates whether the MIME content of an item or attachment is returned in a response. </param>
        /// <param name="attachmentIds">Contains the identifiers of the attachments to return in the response.</param>
        /// <returns>A response message for "GetAttachment" operation.</returns>
        protected GetAttachmentResponseType CallGetAttachmentOperation(BodyTypeResponseType bodyType, bool includeMimeContent, params AttachmentIdType[] attachmentIds)
        {
            GetAttachmentType getAttachmentRequest = new GetAttachmentType()
            {
                AttachmentIds = attachmentIds,

                AttachmentShape = new AttachmentResponseShapeType()
                {
                    BodyType                    = bodyType,
                    BodyTypeSpecified           = true,
                    IncludeMimeContent          = includeMimeContent,
                    IncludeMimeContentSpecified = true,
                    AdditionalProperties        = new BasePathToElementType[]
                    {
                        new PathToIndexedFieldType()
                        {
                            FieldURI   = DictionaryURIType.itemInternetMessageHeader,
                            FieldIndex = string.Empty
                        },
                        new PathToUnindexedFieldType()
                        {
                            FieldURI = UnindexedFieldURIType.itemDateTimeCreated
                        }
                    }
                }
            };

            return(this.ATTAdapter.GetAttachment(getAttachmentRequest));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets a specific attachment from exchange by id.
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public FileAttachmentType GetAttachment(string id)
        {
            var binding = ChannelHelper.BuildChannel(hostname, username, password);
            var getAttachmentRequest = new GetAttachmentType();

            var attachmentIdArray = new RequestAttachmentIdType[1];

            attachmentIdArray[0] = new RequestAttachmentIdType {
                Id = id
            };

            getAttachmentRequest.AttachmentIds = attachmentIdArray;

            GetAttachmentResponseType getAttachmentResponse = binding.GetAttachment(getAttachmentRequest);

            if (getAttachmentResponse.ResponseMessages.Items[0].ResponseClass == ResponseClassType.Error)
            {
                throw new Exception(getAttachmentResponse.ResponseMessages.Items[0].MessageText);
            }

            var attachmentResponseMessage =
                (AttachmentInfoResponseMessageType)getAttachmentResponse.ResponseMessages.Items[0];

            if (attachmentResponseMessage.Attachments == null || attachmentResponseMessage.Attachments.Length == 0)
            {
                throw new ApplicationException("Error in GetAttachment, empty AttachmentInfoResponseMessageType");
            }

            return((FileAttachmentType)attachmentResponseMessage.Attachments[0]);
        }
        /// <summary>
        /// Gets an attachment from an item in the server store.
        /// </summary>
        /// <param name="getAttachmentRequest">A GetAttachmentType complex type specifies a request message to get attached items and files on an item in the server database.</param>
        /// <returns>A GetAttachmentResponseType complex type specifies the response message that is returned by the GetAttachment operation.</returns>
        public GetAttachmentResponseType GetAttachment(GetAttachmentType getAttachmentRequest)
        {
            GetAttachmentResponseType getAttachmentResponse = this.exchangeServiceBinding.GetAttachment(getAttachmentRequest);

            Site.Assert.IsNotNull(getAttachmentResponse, "If the operation is successful, the response should not be null.");

            this.VerifySoapVersion();
            this.VerifyTransportType();
            this.VerifyServerVersionInfo(this.exchangeServiceBinding.IsSchemaValidated);
            this.VerifyGetAttachmentResponse(getAttachmentResponse, this.exchangeServiceBinding.IsSchemaValidated);
            return(getAttachmentResponse);
        }
 /// <remarks/>
 public void GetAttachmentAsync(GetAttachmentType GetAttachment1, object userState)
 {
     if ((this.GetAttachmentOperationCompleted == null))
     {
         this.GetAttachmentOperationCompleted = new System.Threading.SendOrPostCallback(this.OnGetAttachmentOperationCompleted);
     }
     this.InvokeAsync("GetAttachment", new object[] {
                 GetAttachment1}, this.GetAttachmentOperationCompleted, userState);
 }
 /// <remarks/>
 public void GetAttachmentAsync(GetAttachmentType GetAttachment1)
 {
     this.GetAttachmentAsync(GetAttachment1, null);
 }
 /// <remarks/>
 public System.IAsyncResult BeginGetAttachment(GetAttachmentType GetAttachment1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetAttachment", new object[] {
                 GetAttachment1}, callback, asyncState);
 }