예제 #1
0
 /// <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);
 }
예제 #2
0
 /// <remarks/>
 public System.IAsyncResult BeginGetAttachment(GetAttachmentType GetAttachment1, System.AsyncCallback callback, object asyncState)
 {
     return this.BeginInvoke("GetAttachment", new object[] {
             GetAttachment1}, callback, asyncState);
 }
예제 #3
0
 /// <remarks/>
 public void GetAttachmentAsync(GetAttachmentType GetAttachment1)
 {
     this.GetAttachmentAsync(GetAttachment1, null);
 }
예제 #4
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];
        }