Working with Email Messages

View as MarkdownMarkdown

Set up your AI agent

Give your coding agent live access to the GroupDocs documentation and API reference through the GroupDocs Docs MCP server — no install, no API key. Learn more

claude mcp add --transport http groupdocs-docs https://docs.groupdocs.com/mcp

Also process documents locally

The GroupDocs.Assembly MCP server lets your agent work with files on your machine; they are never uploaded. It needs the .NET 10 SDK or Docker.

claude mcp add groupdocs-assembly -- dnx GroupDocs.Assembly.Mcp --yes
Folders, licensing and more →
Note
The example reads the shop data described in The Business Layer.

Working with Email Messages

GroupDocs.Assembly allows you to use data bands in table rows in Email Messageswith HTML and RTF bodies. A table-row data band is a data band which body occupies single or multiple rows of a single document table. The body of such a band starts at the beginning of the first occupied row and ends at the end of the last occupied row as follows. The syntax for using data bands in email messages is as follows:

ManagerManagerContract Price
<<foreach [c in ds]>><<[c.Client]>><<[c.Manager]>><<[c.Price]>><</foreach>>

Working with Table-Row Conditional Blocks

You can also use a table-row conditional block which body occupies single or multiple rows of a single document table. The body of such a block (as well as the body of its every template option) starts at the beginning of the first occupied row and ends at the end of the last occupied row as follows:

<<if …» ………
………
<<elseif …» ………
………
<<else» ………
………
……… <</if»

Download

Data Source Document

Template

The Code

from groupdocs.assembly import DataSourceInfo, DocumentAssembler
from groupdocs.assembly.data import DocumentTable, DocumentTableOptions

options = DocumentTableOptions()
options.first_row_contains_column_names = True
table = DocumentTable("contracts.xlsx", 0, options)

assembler = DocumentAssembler()
assembler.assemble_document("data-table.msg", "data-table-report.msg", [
    DataSourceInfo(table, "ds"),
    DataSourceInfo("Harbor Lane Provisions <orders@harborlane.example>", "sender"),
    DataSourceInfo(["Quayside Bistro <orders@quaysidebistro.example>", "jonas.weber@harborlane.example"], "recipients"),
    DataSourceInfo("amara.osei@harborlane.example", "cc"),
    DataSourceInfo("Data table", "subject"),
])

The following sample file is used in this example: data-table.msg

The following sample file is used in this example: contracts.xlsx

Binary file (MSG, 47 KB)

Download full output