WordMailMergeAgentTools Class
Provides agent tools for mail merge operations in Word documents. Handles executing mail merge with various data sources and merge options.
Inherited Members
Namespace: Syncfusion.AI.AgentTools.Word
Assembly: Syncfusion.DocumentSDK.AI.AgentTools.dll
Syntax
public class WordMailMergeAgentTools : AgentToolBase<WordDocument>
Constructors
WordMailMergeAgentTools(DocumentStorageManager)
Initializes a new instance of the WordMailMergeAgentTools class (Mode 2 — DocumentStorage).
Declaration
public WordMailMergeAgentTools(DocumentStorageManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| DocumentStorageManager | manager | The document storage manager. |
WordMailMergeAgentTools(WordDocumentManager)
Initializes a new instance of the WordMailMergeAgentTools class (Mode 1 — InMemory).
Declaration
public WordMailMergeAgentTools(WordDocumentManager manager)
Parameters
| Type | Name | Description |
|---|---|---|
| WordDocumentManager | manager | The document manager for managing Word documents. |
Methods
ExecuteGroupMailMerge(String, String, String, Boolean, Boolean, Boolean, Boolean, Boolean, String)
Executes a mail merge operation in the Word document using a data table.
Declaration
[Tool(Name = "ExecuteGroupMailMerge", Description = "Executes a mail merge operation in the Word document using a DataTable. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Options: RemoveEmptyFields, RemoveEmptyGroup, RestartNumberingInLists, InsertAsNewRow.")]
public AgentToolResult ExecuteGroupMailMerge([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "JSON representation of the data table with rows and columns")] string dataTableJson, [ToolParameter(Description = "The group name used in the mail merge template (e.g. 'Employees'). Required when the JSON is a plain array; ignored when the JSON object already contains a named property.")] string groupName = "", [ToolParameter(Description = "Whether to remove empty merge fields (true/false)")] bool removeEmptyFields = true, [ToolParameter(Description = "Whether to remove empty groups (true/false)")] bool removeEmptyGroup = true, [ToolParameter(Description = "Whether to remove unmerged merge fields from the document after mail merge. true = remove unmerged fields (default); false = keep unmerged fields as-is in the output document.")] bool clearFields = true, [ToolParameter(Description = "Whether to remove empty paragraphs that contain only a merge field with no data during mail merge. (true/false)")] bool removeEmptyParagraphs = true, [ToolParameter(Description = "Whether to start each group record on a new page. Valid only when group start and end are in the text body (not in tables, headers, or footers). (true/false)")] bool startAtNewPage = false, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | dataTableJson | JSON string representing the data table used for mail merge. |
| System.String | groupName | The group name defined in the mail merge template. |
| System.Boolean | removeEmptyFields | Specifies whether empty merge fields should be removed. |
| System.Boolean | removeEmptyGroup | Specifies whether empty mail merge groups should be removed. |
| System.Boolean | clearFields | Specifies whether unmerged merge fields should be removed after mail merge. |
| System.Boolean | removeEmptyParagraphs | Specifies whether empty paragraphs created during mail merge should be removed. |
| System.Boolean | startAtNewPage | Specifies whether each group record should start on a new page. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure of the mail merge operation, along with details of the generated document. |
ExecuteMailMerge(String, String, Boolean, Boolean, String)
Extended mail merge with field mappings and multiple document output.
Declaration
[Tool(Name = "ExecuteMailMerge", Description = "Extended mail merge with field mappings and output options for batch generation. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Returns document IDs of generated documents.")]
public AgentToolResult ExecuteMailMerge([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode) of the template document")] string documentIdOrFilePath, [ToolParameter(Description = "Either a file path to a JSON file (e.g. 'C:\\data\\records.json') or a raw JSON string containing the data source")] string dataSourceJson, [ToolParameter(Description = "Whether to remove the empty paragraphs when the paragraph has only a merge field item, without any data during Mail merge process. (true/false)")] bool removeEmptyParagraphs = true, [ToolParameter(Description = "Whether to remove unmerged merge fields from the document after mail merge. true = remove unmerged fields (default); false = keep unmerged fields as-is in the output document.")] bool clearFields = true, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode) of the template document. |
| System.String | dataSourceJson | JSON data source provided as a file path or a raw JSON string. |
| System.Boolean | removeEmptyParagraphs | Specifies whether empty paragraphs created during mail merge should be removed. |
| System.Boolean | clearFields | Specifies whether unmerged merge fields should be removed after mail merge. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating success or failure of the mail merge operation, along with details of the generated document. |
ExecuteNestedGroupMailMerge(String, String, String, Boolean, Boolean, Boolean, Boolean, Boolean, String)
Executes a mail merge operation in the Word document using a data table.
Declaration
[Tool(Name = "ExecuteNestedGroupMailMerge", Description = "Executes a nested group mail merge operation in the Word document using a DataTable. documentIdOrFilePath: The document ID (InMemory mode) or input file path (DocumentStorage mode). Options: RemoveEmptyFields, RemoveEmptyGroup, RestartNumberingInLists, InsertAsNewRow.")]
public AgentToolResult ExecuteNestedGroupMailMerge([ToolParameter(Description = "The document ID (InMemory mode) or input file path (DocumentStorage mode)")] string documentIdOrFilePath, [ToolParameter(Description = "JSON representation of the data table with rows and columns")] string dataTableJson, [ToolParameter(Description = "The group name used in the mail merge template (e.g. 'Employees'). Required when the JSON is a plain array; ignored when the JSON object already contains a named property.")] string groupName = "", [ToolParameter(Description = "Whether to remove empty merge fields (true/false)")] bool removeEmptyFields = true, [ToolParameter(Description = "Whether to remove empty groups (true/false)")] bool removeEmptyGroup = true, [ToolParameter(Description = "Whether to remove unmerged merge fields from the document after mail merge. true = remove unmerged fields (default); false = keep unmerged fields as-is in the output document.")] bool clearFields = true, [ToolParameter(Description = "Whether to remove empty paragraphs that contain only a merge field with no data during mail merge. (true/false)")] bool removeEmptyParagraphs = true, [ToolParameter(Description = "Whether to start each group record on a new page. Valid only when group start and end are in the text body (not in tables, headers, or footers). (true/false)")] bool startAtNewPage = false, [ToolParameter(Description = "Output file path for saving the result (DocumentStorage mode only).")] string outputFilePath = null)
Parameters
| Type | Name | Description |
|---|---|---|
| System.String | documentIdOrFilePath | The document ID (InMemory mode) or input file path (DocumentStorage mode). |
| System.String | dataTableJson | JSON string representing the data table used for nested group mail merge. |
| System.String | groupName | The group name defined in the mail merge template. |
| System.Boolean | removeEmptyFields | Specifies whether empty merge fields should be removed. |
| System.Boolean | removeEmptyGroup | Specifies whether empty groups should be removed. |
| System.Boolean | clearFields | Specifies whether unmerged merge fields should be removed after mail merge. |
| System.Boolean | removeEmptyParagraphs | Specifies whether empty paragraphs created during mail merge should be removed. |
| System.Boolean | startAtNewPage | Specifies whether each group record should start on a new page. |
| System.String | outputFilePath | Output file path for saving the result (DocumentStorage mode only). |
Returns
| Type | Description |
|---|---|
| AgentToolResult | Result indicating whether the nested group mail merge operation succeeded. |