MailMerge

function MailMerge(
  nStartIndex: number = 0,
  nEndIndex: number = Api.GetMailMergeReceptionsCount() - 1,
): boolean

Description

Starts the mail merge process.

Parameters

nStartIndexnumberdefault: 0

The start index of the document for mail merge process.

nEndIndexnumberdefault: Api.GetMailMergeReceptionsCount() - 1

The end index of the document for mail merge process.

Returns

boolean

Try It

var oDocument = Api.GetDocument();
var oParagraph = oDocument.GetElement(0);
var arrField = ["Greeting line", "First name", "Last name"];
for (let i = 0; i < 3; i++) {
   var oRun = Api.CreateRun();
   oRun.AddText(arrField[i]);
   oParagraph.AddElement(oRun);
   oRun.WrapInMailMergeField();
   oParagraph.AddText(" ");
}
oParagraph.AddText("!");
Api.LoadMailMergeData([arrField, ["Dear", "John", "Smith"], ["Hello", "Lara", "Davis"]]);
Api.MailMerge(1);

Get Help

  • If you have any questions about ONLYOFFICE Docs, try the FAQ section first.
  • You can request a feature or report a bug by posting an issue on GitHub.
  • You can also ask our developers on ONLYOFFICE forum (registration required).