Aspose::Words::MailMerging::MailMergeRegionInfo class

MailMergeRegionInfo class

Contains information about a mail merge region. To learn more, visit the Mail Merge and Reporting documentation article.

class MailMergeRegionInfo : public System::Object

Methods

MethodDescription
get_EndField() constReturns an end field for the region.
get_EndMustacheTag() constReturns an end “mustache” tag for the region.
get_Fields() constReturns a list of child fields.
get_Level() constReturns the nesting level for the region.
get_MustacheTags() constReturns a list of child “mustache” tags.
get_Name() constReturns the name of region.
get_ParentRegion() constReturns parent region info (null for top-level region).
get_Regions() constReturns a list of child regions.
get_StartField() constReturns a start field for the region.
get_StartMustacheTag() constReturns a start “mustache” tag for the region.
GetType() const override
Is(const System::TypeInfo&) const override
static Type()

Examples

Shows how to verify mail merge regions.

auto doc = MakeObject<Document>(MyDir + u"Mail merge regions.docx");

// Returns a full hierarchy of merge regions that contain MERGEFIELDs available in the document.
SharedPtr<MailMergeRegionInfo> regionInfo = doc->get_MailMerge()->GetRegionsHierarchy();

// Get top regions in the document.
SharedPtr<System::Collections::Generic::IList<SharedPtr<MailMergeRegionInfo>>> topRegions = regionInfo->get_Regions();

ASSERT_EQ(2, topRegions->get_Count());
ASSERT_EQ(u"Region1", topRegions->idx_get(0)->get_Name());
ASSERT_EQ(u"Region2", topRegions->idx_get(1)->get_Name());
ASSERT_EQ(1, topRegions->idx_get(0)->get_Level());
ASSERT_EQ(1, topRegions->idx_get(1)->get_Level());

// Get nested region in first top region.
SharedPtr<System::Collections::Generic::IList<SharedPtr<MailMergeRegionInfo>>> nestedRegions = topRegions->idx_get(0)->get_Regions();

ASSERT_EQ(2, nestedRegions->get_Count());
ASSERT_EQ(u"NestedRegion1", nestedRegions->idx_get(0)->get_Name());
ASSERT_EQ(u"NestedRegion2", nestedRegions->idx_get(1)->get_Name());
ASSERT_EQ(2, nestedRegions->idx_get(0)->get_Level());
ASSERT_EQ(2, nestedRegions->idx_get(1)->get_Level());

// Get list of fields inside the first top region.
SharedPtr<System::Collections::Generic::IList<SharedPtr<Field>>> fieldList = topRegions->idx_get(0)->get_Fields();

ASSERT_EQ(4, fieldList->get_Count());

SharedPtr<FieldMergeField> startFieldMergeField = nestedRegions->idx_get(0)->get_StartField();

ASSERT_EQ(u"TableStart:NestedRegion1", startFieldMergeField->get_FieldName());

SharedPtr<FieldMergeField> endFieldMergeField = nestedRegions->idx_get(0)->get_EndField();

ASSERT_EQ(u"TableEnd:NestedRegion1", endFieldMergeField->get_FieldName());

See Also