/// <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); }
public void MSOXWSATT_S01_TC02_ProcessMessageTypeItemAttachment() { Site.Assume.IsTrue(Common.IsRequirementEnabled(318013, this.Site), "Exchange 2007 does not use the FilterHtmlContent element."); #region Step 1 Create an item attachment, which contains a MessageType item as the child item, on an item. // Create an item attachment by CreateAttachment operation. CreateAttachmentResponseType createAttachmentResponse = this.CallCreateAttachmentOperation(this.ItemId.Id, AttachmentTypeValue.MessageAttachment); AttachmentInfoResponseMessageType createAttachmentInfoResponse = createAttachmentResponse.ResponseMessages.Items[0] as AttachmentInfoResponseMessageType; // Check the response. Common.CheckOperationSuccess(createAttachmentResponse, 1, this.Site); this.VerifyCreateAttachmentSuccessfulResponse(createAttachmentResponse); // Gets the ID of the created attachment. AttachmentType createdAttachment = createAttachmentInfoResponse.Attachments[0]; AttachmentIdType createdAttachmentId = createdAttachment.AttachmentId; #endregion #region Step 2 Get the item attachment created in step 1 by the GetAttachment operation. GetAttachmentType getAttachmentRequest = new GetAttachmentType() { AttachmentIds = new AttachmentIdType[] { createdAttachmentId }, AttachmentShape = new AttachmentResponseShapeType() { BodyType = BodyTypeResponseType.Text, BodyTypeSpecified = true, IncludeMimeContent = true, IncludeMimeContentSpecified = true, } }; GetAttachmentResponseType getAttachmentResponse = this.ATTAdapter.GetAttachment(getAttachmentRequest); AttachmentInfoResponseMessageType getAttachmentInfoResponse = getAttachmentResponse.ResponseMessages.Items[0] as AttachmentInfoResponseMessageType; // Check the response. Common.CheckOperationSuccess(getAttachmentResponse, 1, this.Site); #endregion if (Common.IsRequirementEnabled(55001, this.Site)) { // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R55001"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R55001 // If the MIMEContent of returned attachment is not null, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.MimeContent, 55001, @"[In Appendix C: Product Behavior] Implementation does return MIME content.(<10> Section 3.1.4.3.3.3: In Exchange 2007, Exchange 2010, Microsoft Exchange Server 2010 Service Pack 1 (SP1) and Microsoft Exchange Server 2010 Service Pack 2 (SP2), If the IncludeMimeContent element is set to true in the AttachmentResponseShapeType complex type, the MIME content will be returned for attachment of the item class: IPM.Note.)"); } // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R202"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R202 // If the attachment created in step 1 is successfully returned, this requirement can be captured. Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, getAttachmentInfoResponse.ResponseClass, 202, @"[In DeleteAttachment Operation] Before an item attachment can be deleted, it MUST be retrieved from the server."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R416"); bool isR416Verified = getAttachmentInfoResponse.ResponseClass == ResponseClassType.Success && getAttachmentInfoResponse.Attachments[0].AttachmentId.Id != null; // Verify MS-OXWSATT requirement: MS-OXWSATT_R416 Site.CaptureRequirementIfIsTrue( isR416Verified, 416, @"[In t:AttachmentType Complex Type][The AttachmentId element] specifies the attachment identifier."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R63"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R63 // If the ContentLocation of returned attachment is same as the one of attachment created in step 1, this requirement can be captured. Site.CaptureRequirementIfAreEqual<string>( @"http://www.contoso.com/xyz.abc", getAttachmentInfoResponse.Attachments[0].ContentLocation, 63, @"[In t:AttachmentType Complex Type][The ContentLocation element] specifies the URI that corresponds to the location of the content of the attachment."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R36"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R36 this.Site.CaptureRequirementIfIsInstanceOfType( getAttachmentInfoResponse.Attachments[0], typeof(ItemAttachmentType), 36, @"[In t:ArrayOfAttachmentsType Complex Type][The ItemAttachment element] specifies an item that is attached to another item."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R349"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R349 // When the created attachment is returned successfully, this requirement can be captured. Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, getAttachmentInfoResponse.ResponseClass, 349, @"[In t:ItemAttachmentType Complex Type][The type of Message element is] t:MessageType ([MS-OXWSMSG] section 2.2.4.1)"); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R83"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R83 // When the created attachment is returned successfully, this requirement can be captured. Site.CaptureRequirementIfAreEqual<ResponseClassType>( ResponseClassType.Success, getAttachmentInfoResponse.ResponseClass, 83, @"[In t:ItemAttachmentType Complex Type][The Message element] Represents a server e-mail message."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R475"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R475 // if all of additional properties are returned successfully, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.DateTimeCreated, 475, @"[In m:GetAttachmentType Complex Type][The AttachmentShape element] Contains additional properties to return for the attachments."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R521"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R521 // if one of additional properties is returned successfully, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.DateTimeCreated, 521, @"[In Complex Types] [Complex type name]AttachmentResponseShapeType Specifies additional properties for the GetAttachment operation to return."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R549"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R549 // if one of additional properties is returned successfully, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.DateTimeCreated, 549, @"[In t:AttachmentResponseShapeType Complex Type][The AdditionalProperties element] Contains additional properties to return in a response."); // Add the debug information this.Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R478"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R478 this.Site.CaptureRequirementIfAreEqual<string>( BodyTypeResponseType.Text.ToString(), ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.Body.BodyType1.ToString(), 478, @"[In t:AttachmentResponseShapeType Complex Type][The BodyType element] Represents the format of the body text in a response."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSCDATA_R1234"); // Verify MS-OXWSCDATA requirement: MS-OXWSCDATA_R1234 // The element "t:Path" is contained in additional property if additional properties are returned successfully, this requirement can be captured. Site.CaptureRequirementIfIsNotNull( ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item.DateTimeCreated, "MS-OXWSCDATA", 1234, @"[In t:NonEmptyArrayOfPathsToElementType Complex Type] The element ""t:Path"" with type ""t:Path"" specifies a property to be returned in a response."); this.VerifyGetAttachmentSuccessfulResponse(getAttachmentResponse); #region Step 3 Get the item attachment created in step 1 by the GetAttachment operation with FilterHtmlContent is false. getAttachmentRequest = new GetAttachmentType() { AttachmentIds = new AttachmentIdType[] { createdAttachmentId }, AttachmentShape = new AttachmentResponseShapeType() { BodyType = BodyTypeResponseType.HTML, BodyTypeSpecified = true, IncludeMimeContent = true, IncludeMimeContentSpecified = true, FilterHtmlContent = false, FilterHtmlContentSpecified = true, } }; getAttachmentResponse = this.ATTAdapter.GetAttachment(getAttachmentRequest); getAttachmentInfoResponse = getAttachmentResponse.ResponseMessages.Items[0] as AttachmentInfoResponseMessageType; MessageType message = ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R479002"); this.Site.CaptureRequirementIfIsTrue( message.Body.Value.Contains("<script>alert('Alert!');</script>"), 479002, @"[In t:AttachmentResponseShapeType Complex Type][The FilterHtmlContent element] A text value of ""false"" indicates that potentially unsafe HTML content is not to be filtered from the attachment."); #endregion #region Step 4 Get the item attachment created in step 1 by the GetAttachment operation with FilterHtmlContent is true. getAttachmentRequest = new GetAttachmentType() { AttachmentIds = new AttachmentIdType[] { createdAttachmentId }, AttachmentShape = new AttachmentResponseShapeType() { BodyType = BodyTypeResponseType.HTML, BodyTypeSpecified = true, IncludeMimeContent = true, IncludeMimeContentSpecified = true, FilterHtmlContent = true, FilterHtmlContentSpecified = true, } }; getAttachmentResponse = this.ATTAdapter.GetAttachment(getAttachmentRequest); getAttachmentInfoResponse = getAttachmentResponse.ResponseMessages.Items[0] as AttachmentInfoResponseMessageType; message = ((ItemAttachmentType)getAttachmentInfoResponse.Attachments[0]).Item as MessageType; // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R479001"); this.Site.CaptureRequirementIfIsFalse( message.Body.Value.Contains("<script>alert('Alert!');</script>"), 479001, @"[In t:AttachmentResponseShapeType Complex Type][The FilterHtmlContent element] A text value of ""true"" indicates that potentially unsafe HTML content is to be filtered from the attachment."); // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R318013"); // If step above all pass, R318013 will be verified. this.Site.CaptureRequirement( 318013, @"[In Appendix C: Product Behavior] Implementation does support the FilterHtmlContent element. (Exchange 2010 and above follow this behavior.)"); #endregion #region Step 5 Delete the item attachment created in step 1 by the DeleteAttachment operation. DeleteAttachmentResponseType deleteAttachmentResponse = this.CallDeleteAttachmentOperation(createdAttachmentId); DeleteAttachmentResponseMessageType deleteAttachmentResponseMessage = deleteAttachmentResponse.ResponseMessages.Items[0] as DeleteAttachmentResponseMessageType; // Check the response. Common.CheckOperationSuccess(deleteAttachmentResponse, 1, this.Site); #endregion // Add the debug information Site.Log.Add(LogEntryKind.Debug, "Verify MS-OXWSATT_R466"); // Verify MS-OXWSATT requirement: MS-OXWSATT_R466 // if the RootItemId is same as the id of the store item, this requirement can be captured. Site.CaptureRequirementIfAreEqual<string>( this.ItemId.Id, deleteAttachmentResponseMessage.RootItemId.RootItemId, 466, @"[In m:DeleteAttachmentResponseMessageType Complex Type][The RootItemId element] Specifies the parent item of a deleted attachment."); this.VerifyDeleteAttachmentSuccessfulResponse(deleteAttachmentResponse); }
/// <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); }
/// <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; }