Microsoft.Protocols.TestSuites.MS_OXCPERM.MS_OXCPERMAdapter.EditMessage C# (CSharp) Method

EditMessage() private method

Edit the message created by the owner of the mailbox or other user in Inbox.
private EditMessage ( ulong messageId ) : uint
messageId ulong The message Id to edit.
return uint
        private uint EditMessage(ulong messageId)
        {
            RopOpenMessageRequest openMessageRequest;
            RopOpenMessageResponse openMessageResponse;
            openMessageRequest.RopId = 0x03; // RopId 0x03 indicates RopOpenMessage
            openMessageRequest.LogonId = 0x00; // The logonId 0x00 is associated with this operation.
            openMessageRequest.InputHandleIndex = 0x00; // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored. 
            openMessageRequest.OutputHandleIndex = 0x01; // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored. 
            openMessageRequest.CodePageId = 0x0FFF; // Code page of Logon object is used
            openMessageRequest.FolderId = this.ropLogonResponse.FolderIds[4]; // Open the message in INBOX folder in which message is created.
            openMessageRequest.OpenModeFlags = 0x01; // The message will be opened as read-write
            openMessageRequest.MessageId = messageId; // Open the saved message
            this.responseSOHs = this.DoRopCall(openMessageRequest, this.inobjHandle, ref this.response, ref this.rawData);
            openMessageResponse = (RopOpenMessageResponse)this.response;
            if (UINT32SUCCESS != openMessageResponse.ReturnValue)
            {
                return openMessageResponse.ReturnValue;
            }

            uint targetMessageHandle = this.responseSOHs[0][openMessageResponse.OutputHandleIndex];

            TaggedPropertyValue[] tags = new TaggedPropertyValue[2];

            // PidTagSubject
            PropertyTag pt = new PropertyTag
            {
                PropertyId = 0x0037,
                PropertyType = 0x001F
            };
            TaggedPropertyValue tpv0 = new TaggedPropertyValue
            {
                PropertyTag = pt
            };
            if (this.messageIdsCreatedByOther.Contains(messageId))
            {
                tpv0.Value = Encoding.Unicode.GetBytes("EditTheSubjectCreatedByAdminEditedbyUser1" + StringNullTerminator);
            }
            else
            {
                tpv0.Value = Encoding.Unicode.GetBytes("EditTheSubjectCreatedByCommUserEditedbyUser1: " + this.ownedMessageIndex++ + StringNullTerminator);
            }

            tags[0] = tpv0;

            // PidTagNormalizedSubject
            PropertyTag pt0 = new PropertyTag
            {
                PropertyId = 0x0E1D,
                PropertyType = 0x001F
            };
            TaggedPropertyValue tpv1 = new TaggedPropertyValue
            {
                PropertyTag = pt0,
                Value = tpv0.Value
            };
            tags[1] = tpv1;

            #region Construct the request buffer
            RopSetPropertiesRequest setPropertiesRequest = new RopSetPropertiesRequest
            {
                RopId = 0x0A,
                LogonId = 0x0,
                InputHandleIndex = 0x0,
                PropertyValueSize = (ushort)(tags[0].Size() + tags[1].Size() + 2),
                PropertyValueCount = (ushort)tags.Length,
                PropertyValues = tags
            };

            #endregion

            this.DoRopCall(setPropertiesRequest, targetMessageHandle, ref this.response, ref this.rawData);
            RopSetPropertiesResponse setPropertiesResponse = (RopSetPropertiesResponse)this.response;
            if (UINT32SUCCESS != setPropertiesResponse.ReturnValue)
            {
                return setPropertiesResponse.ReturnValue;
            }

            RopSaveChangesMessageRequest saveChangesMessageRequest;
            RopSaveChangesMessageResponse saveChangesMessageResponse;
            saveChangesMessageRequest.RopId = 0x0C; // RopId 0x0C indicates RopSaveChangesMessage 
            saveChangesMessageRequest.LogonId = 0x00; // The logonId 0x00 is associated with this operation.
            saveChangesMessageRequest.InputHandleIndex = 0x00; // This index specifies the location 0x00 in the Server Object Handle Table where the handle for the input Server Object is stored. 
            saveChangesMessageRequest.ResponseHandleIndex = 0x01; // This index specifies the location 0x01 in the Server Object Handle Table where the handle for the output Server Object is stored. 
            saveChangesMessageRequest.SaveFlags = 0x0C; // ForceSave
            this.DoRopCall(saveChangesMessageRequest, targetMessageHandle, ref this.response, ref this.rawData);
            saveChangesMessageResponse = (RopSaveChangesMessageResponse)this.response;
            if (UINT32SUCCESS != saveChangesMessageResponse.ReturnValue)
            {
                return saveChangesMessageResponse.ReturnValue;
            }

            // Release the message 
            this.ReleaseObject(targetMessageHandle);

            return UINT32SUCCESS;
        }
MS_OXCPERMAdapter