Microsoft.Protocols.TestSuites.MS_OXORULE.MS_OXORULEAdapter.CreateReplyTemplate C# (CSharp) Method

CreateReplyTemplate() public method

Create Reply Template use settings in Util.cs file. It will be used by create Rule of ActioType: OP_REPLY
public CreateReplyTemplate ( uint inboxFolderHandle, ulong inboxFolderID, bool isOOFReplyTemplate, string templateSubject, TaggedPropertyValue addedProperties, ulong &messageId, uint &messageHandler ) : byte[]
inboxFolderHandle uint The inbox folder's handle.
inboxFolderID ulong The inbox folder's ID.
isOOFReplyTemplate bool Indicate whether the template to be created is a template for OP_REPLY or OP_OOF_REPLY .
templateSubject string The name of the template.
addedProperties Microsoft.Protocols.TestSuites.Common.TaggedPropertyValue The properties that need to add to the reply template.
messageId ulong Message id of reply template message.
messageHandler uint The reply message Handler.
return byte[]
        public byte[] CreateReplyTemplate(uint inboxFolderHandle, ulong inboxFolderID, bool isOOFReplyTemplate, string templateSubject, TaggedPropertyValue[] addedProperties, out ulong messageId, out uint messageHandler)
        {
            // Create a new FAI message in the inbox folder
            RopCreateMessageResponse ropCreateMessageResponse = new RopCreateMessageResponse();
            messageHandler = this.RopCreateMessage(inboxFolderHandle, inboxFolderID, Convert.ToByte(true), out ropCreateMessageResponse);

            #region Set the new created message's properties
            TaggedPropertyValue[] replyTemplateProperties = new TaggedPropertyValue[3];

            // PidTagMessageClass
            replyTemplateProperties[0] = new TaggedPropertyValue();
            PropertyTag replyTemplatePropertiesPropertyTag = new PropertyTag
            {
                PropertyType = (ushort)PropertyType.PtypString,
                PropertyId = (ushort)PropertyId.PidTagMessageClass
            };
            replyTemplateProperties[0].PropertyTag = replyTemplatePropertiesPropertyTag;
            if (isOOFReplyTemplate == true)
            {
                replyTemplateProperties[0].Value = Encoding.Unicode.GetBytes(Constants.OOFReplyTemplate + "\0");
            }
            else
            {
                replyTemplateProperties[0].Value = Encoding.Unicode.GetBytes(Constants.ReplyTemplate + "\0");
            }

            // PidTagReplyTemplateId
            replyTemplateProperties[1] = new TaggedPropertyValue();
            PropertyTag pidTagReplyTemplateIdPropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagReplyTemplateId,
                PropertyType = (ushort)PropertyType.PtypBinary
            };
            replyTemplateProperties[1].PropertyTag = pidTagReplyTemplateIdPropertyTag;
            Guid newGuid = System.Guid.NewGuid();
            replyTemplateProperties[1].Value = Common.AddInt16LengthBeforeBinaryArray(newGuid.ToByteArray());

            // PidTagSubject
            replyTemplateProperties[2] = new TaggedPropertyValue();
            PropertyTag pidTagSubjectPropertyTag = new PropertyTag
            {
                PropertyId = (ushort)PropertyId.PidTagSubject,
                PropertyType = (ushort)PropertyType.PtypString
            };
            replyTemplateProperties[2].PropertyTag = pidTagSubjectPropertyTag;
            replyTemplateProperties[2].Value = Encoding.Unicode.GetBytes(templateSubject + "\0");

            this.RopSetProperties(messageHandler, replyTemplateProperties);
            this.RopSetProperties(messageHandler, addedProperties);
            #endregion

            // Save changes of the message
            RopSaveChangesMessageResponse ropSaveChangesMessagResponse = this.RopSaveChangesMessage(messageHandler);
            messageId = ropSaveChangesMessagResponse.MessageId;
            return newGuid.ToByteArray();
        }