/// <summary> /// Call SmartForward command to forward an email. /// </summary> /// <param name="itemServerId">The ServerId of the email to reply.</param> /// <param name="collectionId">The folder collectionId of the source email.</param> /// <param name="from">The mailbox address of sender.</param> /// <param name="forwardTo">The mailbox address of recipient.</param> /// <param name="subject">The subject of the email to reply.</param> protected void CallSmartForwardCommand(string itemServerId, string collectionId, string from, string forwardTo, string subject) { // Create SmartForward command request. Request.Source source = new Request.Source(); string mime = Common.CreatePlainTextMime(from, forwardTo, string.Empty, string.Empty, subject, "SmartForward content"); SmartForwardRequest smartForwardRequest = Common.CreateSmartForwardRequest(null, System.Guid.NewGuid().ToString(), mime, source); // Set the command parameters. smartForwardRequest.SetCommandParameters(new Dictionary <CmdParameterName, object>()); source.FolderId = collectionId; source.ItemId = itemServerId; smartForwardRequest.CommandParameters.Add(CmdParameterName.CollectionId, collectionId); smartForwardRequest.CommandParameters.Add(CmdParameterName.ItemId, itemServerId); smartForwardRequest.RequestData.ReplaceMime = string.Empty; // Call SmartForward command. SmartForwardResponse smartForwardResponse = this.CONAdapter.SmartForward(smartForwardRequest); Site.Assert.AreEqual(string.Empty, smartForwardResponse.ResponseDataXML, "The SmartForward command should be executed successfully."); }
/// <summary> /// Call SmartReply command to reply an email. /// </summary> /// <param name="from">The mailbox address of sender.</param> /// <param name="replyTo">The mailbox address recipient.</param> /// <param name="itemServerId">The ServerId of the email to forward.</param> /// <param name="replySubject">The subject of the email to reply.</param> /// <param name="saveInSent">The value of SaveInSent command parameter.</param> /// <param name="longId">The value of LongId command parameter.</param> /// <param name="occurrence">The value of Occurrence command parameter.</param> protected void CallSmartReplyCommand(string from, string replyTo, string itemServerId, string replySubject, string saveInSent, string longId, string occurrence) { // Create SmartReply command request. Request.Source source = new Request.Source(); string mime = Common.CreatePlainTextMime(from, replyTo, string.Empty, string.Empty, replySubject, "SmartReply content"); SmartReplyRequest request = Common.CreateSmartReplyRequest(null, System.Guid.NewGuid().ToString(), mime, source); // Set the command parameters. // If the LongId element is present, the FolderId, ItemId, and InstanceId elements are not present. request.SetCommandParameters(new Dictionary<CmdParameterName, object>()); if (longId == null) { string collectionId = itemServerId.Split(':')[0]; if (saveInSent != null) { int result; if (int.TryParse(saveInSent, out result)) { request.CommandParameters.Add(CmdParameterName.Options, result); if (result == 1) { request.RequestData.SaveInSentItems = string.Empty; } } else { request.CommandParameters.Add(CmdParameterName.SaveInSent, saveInSent); if (saveInSent == "T") { request.RequestData.SaveInSentItems = string.Empty; } } } // If the InstanceId element is present, both the FolderId and ItemId elements SHOULD be present. if (occurrence != null) { request.RequestData.Source.InstanceId = occurrence; request.CommandParameters.Add(CmdParameterName.Occurrence, occurrence); } source.FolderId = collectionId; source.ItemId = itemServerId; request.CommandParameters.Add(CmdParameterName.CollectionId, collectionId); request.CommandParameters.Add(CmdParameterName.ItemId, itemServerId); } else { request.RequestData.Source.LongId = longId; request.CommandParameters.Add(CmdParameterName.LongId, longId); } // Call SmartReply command by HTTP POST. SendStringResponse smartReplyResponse = this.HTTPAdapter.HTTPPOST(CommandName.SmartReply, request.CommandParameters, request.GetRequestDataSerializedXML()); // Check the command is executed successfully. this.CheckResponseStatus(smartReplyResponse.ResponseDataXML); }