com.aspose.words

Class MailMergeSettings

  • java.lang.Object
    • com.aspose.words.MailMergeSettings
  • All Implemented Interfaces:
    java.lang.Cloneable
    public class MailMergeSettings 
    extends java.lang.Object

Specifies all of the mail merge information for a document.

You can use this object to specify a mail merge data source for a document and this information (along with the available data fields) will appear in Microsoft Word when the user opens this document. Or you can use this object to query mail merge settings that the user has specified in Microsoft Word for this document.

You do not normally need to create objects of this class directly because Mail merge settings of a document are always available via the Document.MailMergeSettings property.

To detect whether this document is a mail merge main document, check the value of the MainDocumentType property.

To remove mail merge settings and data source information from a document you can use the clear() method. Aspose.Words will not write mail merge settings to a document if the MainDocumentType property is set to MailMergeMainDocumentType.NOT_A_MERGE_DOCUMENT or the DataType property is set to MailMergeDataType.NONE.

The best way to learn how to use the properties of this object is to create a document with a desired data source manually in Microsoft Word and then open that document using Aspose.Words and examine the properties of the Document.MailMergeSettings and Odso objects. This is a good approach to take if you want to learn how to programmatically configure a data source, for example.

Aspose.Words preserves mail merge information when loading, saving and converting documents between different formats, but does not use this information when performing its own mail merge using the MailMerge object.

Example:

Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
// We'll create a simple document that will act as a destination for mail merge data
Document doc = new Document();
DocumentBuilder builder = new DocumentBuilder(doc);

builder.write("Dear ");
builder.insertField("MERGEFIELD FirstName", "<FirstName>");
builder.write(" ");
builder.insertField("MERGEFIELD LastName", "<LastName>");
builder.writeln(": ");
builder.insertField("MERGEFIELD Message", "<Message>");

// Also we'll need a data source, in this case it will be an ASCII text file
// We can use any character we want as a delimiter, in this case we'll choose '|'
// The delimiter character is selected in the ODSO settings of mail merge settings
String[] lines = {"FirstName|LastName|Message",
        "John|Doe|Hello! This message was created with Aspose Words mail merge."};

String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
Files.write(Paths.get(dataSrcFilename),
        (lines + System.lineSeparator()).getBytes(UTF_8),
        new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});

// Set the data source, query and other things
MailMergeSettings settings = doc.getMailMergeSettings();
settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
settings.setDataType(MailMergeDataType.NATIVE);
settings.setDataSource(dataSrcFilename);
settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
settings.setLinkToQuery(true);
settings.setViewMergedData(true);

Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
Assert.assertFalse(settings.getDoNotSupressBlankLines());

// Office Data Source Object settings
Odso odso = settings.getOdso();
odso.setDataSource(dataSrcFilename);
odso.setDataSourceType(OdsoDataSourceType.TEXT);
odso.setColumnDelimiter('|');
odso.setFirstRowContainsColumnNames(true);

// ODSO/MailMergeSettings objects can also be cloned
Assert.assertNotSame(odso, odso.deepClone());
Assert.assertNotSame(settings, settings.deepClone());

// The mail merge will be performed when this document is opened
doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
See Also:
Document.MailMergeSettings

Constructor Summary
 
Property Getters/Setters Summary
intgetActiveRecord()
void
setActiveRecord(intvalue)
           Specifies the one-based index of the record from the data source which shall be displayed in Microsoft Word. The default value is 1.
java.lang.StringgetAddressFieldName()
void
setAddressFieldName(java.lang.Stringvalue)
           Specifies the column within the data source that contains e-mail addresses. The default value is an empty string.
intgetCheckErrors()
void
setCheckErrors(intvalue)
           Specifies the type of error reporting which shall be conducted by Microsoft Word when performing a mail merge. The default value is MailMergeCheckErrors.DEFAULT. The value of the property is MailMergeCheckErrors integer constant.
java.lang.StringgetConnectString()
void
setConnectString(java.lang.Stringvalue)
           Specifies the connection string used to connect to an external data source. The default value is an empty string.
java.lang.StringgetDataSource()
void
setDataSource(java.lang.Stringvalue)
           Specifies the path to the mail-merge data source. The default value is an empty string.
intgetDataType()
void
setDataType(intvalue)
           Specifies the type of the mail-merge data source and the method of data access. The default value is MailMergeDataType.DEFAULT. The value of the property is MailMergeDataType integer constant.
intgetDestination()
void
setDestination(intvalue)
           Specifies how Microsoft Word will output the results of a mail merge. The default value is MailMergeDestination.DEFAULT. The value of the property is MailMergeDestination integer constant.
booleangetDoNotSupressBlankLines()
void
           Specifies how an application performing the mail merge shall handle blank lines in the merged documents resulting from the mail merge. The default value is false.
java.lang.StringgetHeaderSource()
void
setHeaderSource(java.lang.Stringvalue)
           Specifies the path to the mail-merge header source. The default value is an empty string.
booleangetLinkToQuery()
void
setLinkToQuery(booleanvalue)
           Not sure about this one. The Microsoft Word Automation Reference suggests that this specifies that the query is executed every time the document is opened in Microsoft Word. But the OOXML specification suggests that this specifies that the query contains a reference to an external query file which contains the actual query. The default value is false.
booleangetMailAsAttachment()
void
setMailAsAttachment(booleanvalue)
           Specifies that the documents produced during a mail merge operation should be emailed as an attachment rather than the body of the actual e-mail. The default value is false.
java.lang.StringgetMailSubject()
void
setMailSubject(java.lang.Stringvalue)
           Specifies the text which shall appear in the subject line of the e-mails or faxes produced during mail merge. The default value is an empty string.
intgetMainDocumentType()
void
           Specifies the mail-merge main document type. The default value is MailMergeMainDocumentType.DEFAULT. The value of the property is MailMergeMainDocumentType integer constant.
OdsogetOdso()
void
setOdso(Odso value)
           Gets or sets the object that specifies the Office Data Source Object (ODSO) settings.
java.lang.StringgetQuery()
void
setQuery(java.lang.Stringvalue)
           Contains the Structured Query Language string that shall be run against the specified external data source to return the set of records which shall be imported into the document when the mail merge operation is performed. The default value is an empty string.
booleangetViewMergedData()
void
setViewMergedData(booleanvalue)
           Specifies that Microsoft Word shall display the data from the specified external data source where merge fields have been inserted (e.g. preview merged data). The default value is false.
 
Method Summary
voidclear()
Clears the mail merge settings in such a way that when the document is saved, no mail merge settings will be saved and it will become a normal document.
MailMergeSettingsdeepClone()
Returns a deep clone of this object.
 

    • Constructor Detail

      • MailMergeSettings

        public MailMergeSettings()
    • Property Getters/Setters Detail

      • getActiveRecord/setActiveRecord

        public int getActiveRecord() / public void setActiveRecord(int value)
        
        Specifies the one-based index of the record from the data source which shall be displayed in Microsoft Word. The default value is 1.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • getAddressFieldName/setAddressFieldName

        public java.lang.String getAddressFieldName() / public void setAddressFieldName(java.lang.String value)
        
        Specifies the column within the data source that contains e-mail addresses. The default value is an empty string.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • getCheckErrors/setCheckErrors

        public int getCheckErrors() / public void setCheckErrors(int value)
        
        Specifies the type of error reporting which shall be conducted by Microsoft Word when performing a mail merge. The default value is MailMergeCheckErrors.DEFAULT. The value of the property is MailMergeCheckErrors integer constant.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getConnectString/setConnectString

        public java.lang.String getConnectString() / public void setConnectString(java.lang.String value)
        
        Specifies the connection string used to connect to an external data source. The default value is an empty string.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • getDataSource/setDataSource

        public java.lang.String getDataSource() / public void setDataSource(java.lang.String value)
        
        Specifies the path to the mail-merge data source. The default value is an empty string.

        Example:

        Shows how to execute a mail merge while drawing data from a header and a data file.
        // Create a mailing label merge header file, which will consist of a table with one row 
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.startTable();
        builder.insertCell();
        builder.write("FirstName");
        builder.insertCell();
        builder.write("LastName");
        builder.endTable();
        
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.Header.docx");
        
        // Create a mailing label merge date file, which will consist of a table with one row and the same amount of columns as 
        // the header table, which will determine the names for these columns
        doc = new Document();
        builder = new DocumentBuilder(doc);
        
        builder.startTable();
        builder.insertCell();
        builder.write("John");
        builder.insertCell();
        builder.write("Doe");
        builder.endTable();
        
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.Data.docx");
        
        // Create a merge destination document with MERGEFIELDS that will accept data
        doc = new Document();
        builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        
        // Configure settings to draw data and headers from other documents
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        // The "header" document contains column names for the data in the "data" document,
        // which will correspond to the names of our MERGEFIELDs
        settings.setHeaderSource(getArtifactsDir() + "Document.MailingLabelMerge.Header.docx");
        settings.setDataSource(getArtifactsDir() + "Document.MailingLabelMerge.Data.docx");
        
        // Configure the rest of the MailMergeSettings object
        settings.setQuery("SELECT * FROM " + settings.getDataSource());
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setDataType(MailMergeDataType.TEXT_FILE);
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        // The mail merge will be performed when this document is opened 
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.docx");
      • getDataType/setDataType

        public int getDataType() / public void setDataType(int value)
        
        Specifies the type of the mail-merge data source and the method of data access. The default value is MailMergeDataType.DEFAULT. The value of the property is MailMergeDataType integer constant.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getDestination/setDestination

        public int getDestination() / public void setDestination(int value)
        
        Specifies how Microsoft Word will output the results of a mail merge. The default value is MailMergeDestination.DEFAULT. The value of the property is MailMergeDestination integer constant.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getDoNotSupressBlankLines/setDoNotSupressBlankLines

        public boolean getDoNotSupressBlankLines() / public void setDoNotSupressBlankLines(boolean value)
        
        Specifies how an application performing the mail merge shall handle blank lines in the merged documents resulting from the mail merge. The default value is false.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getHeaderSource/setHeaderSource

        public java.lang.String getHeaderSource() / public void setHeaderSource(java.lang.String value)
        
        Specifies the path to the mail-merge header source. The default value is an empty string.

        Example:

        Shows how to execute a mail merge while drawing data from a header and a data file.
        // Create a mailing label merge header file, which will consist of a table with one row 
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.startTable();
        builder.insertCell();
        builder.write("FirstName");
        builder.insertCell();
        builder.write("LastName");
        builder.endTable();
        
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.Header.docx");
        
        // Create a mailing label merge date file, which will consist of a table with one row and the same amount of columns as 
        // the header table, which will determine the names for these columns
        doc = new Document();
        builder = new DocumentBuilder(doc);
        
        builder.startTable();
        builder.insertCell();
        builder.write("John");
        builder.insertCell();
        builder.write("Doe");
        builder.endTable();
        
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.Data.docx");
        
        // Create a merge destination document with MERGEFIELDS that will accept data
        doc = new Document();
        builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        
        // Configure settings to draw data and headers from other documents
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        // The "header" document contains column names for the data in the "data" document,
        // which will correspond to the names of our MERGEFIELDs
        settings.setHeaderSource(getArtifactsDir() + "Document.MailingLabelMerge.Header.docx");
        settings.setDataSource(getArtifactsDir() + "Document.MailingLabelMerge.Data.docx");
        
        // Configure the rest of the MailMergeSettings object
        settings.setQuery("SELECT * FROM " + settings.getDataSource());
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setDataType(MailMergeDataType.TEXT_FILE);
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        // The mail merge will be performed when this document is opened 
        doc.save(getArtifactsDir() + "Document.MailingLabelMerge.docx");
      • getLinkToQuery/setLinkToQuery

        public boolean getLinkToQuery() / public void setLinkToQuery(boolean value)
        
        Not sure about this one. The Microsoft Word Automation Reference suggests that this specifies that the query is executed every time the document is opened in Microsoft Word. But the OOXML specification suggests that this specifies that the query contains a reference to an external query file which contains the actual query. The default value is false.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getMailAsAttachment/setMailAsAttachment

        public boolean getMailAsAttachment() / public void setMailAsAttachment(boolean value)
        
        Specifies that the documents produced during a mail merge operation should be emailed as an attachment rather than the body of the actual e-mail. The default value is false.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • getMailSubject/setMailSubject

        public java.lang.String getMailSubject() / public void setMailSubject(java.lang.String value)
        
        Specifies the text which shall appear in the subject line of the e-mails or faxes produced during mail merge. The default value is an empty string.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • getMainDocumentType/setMainDocumentType

        public int getMainDocumentType() / public void setMainDocumentType(int value)
        
        Specifies the mail-merge main document type. The default value is MailMergeMainDocumentType.DEFAULT. The value of the property is MailMergeMainDocumentType integer constant.

        The main document is the document that contains information that is the same for each version of the merged document.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getOdso/setOdso

        public Odso getOdso() / public void setOdso(Odso value)
        
        Gets or sets the object that specifies the Office Data Source Object (ODSO) settings.

        This object is never null.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getQuery/setQuery

        public java.lang.String getQuery() / public void setQuery(java.lang.String value)
        
        Contains the Structured Query Language string that shall be run against the specified external data source to return the set of records which shall be imported into the document when the mail merge operation is performed. The default value is an empty string.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
      • getViewMergedData/setViewMergedData

        public boolean getViewMergedData() / public void setViewMergedData(boolean value)
        
        Specifies that Microsoft Word shall display the data from the specified external data source where merge fields have been inserted (e.g. preview merged data). The default value is false.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");
    • Method Detail

      • clear

        public void clear()
        Clears the mail merge settings in such a way that when the document is saved, no mail merge settings will be saved and it will become a normal document.

        Example:

        Shows how to execute a mail merge while connecting to an external data source.
        Document doc = new Document(getMyDir() + "Odso data.docx");
        MailMergeSettings settings = doc.getMailMergeSettings();
        
        System.out.println(MessageFormat.format("Connection string:\n\t{0}", settings.getConnectString()));
        System.out.println(MessageFormat.format("Mail merge docs as attachment:\n\t{0}", settings.getMailAsAttachment()));
        System.out.println(MessageFormat.format("Mail merge doc e-mail subject:\n\t{0}", settings.getMailSubject()));
        System.out.println(MessageFormat.format("Column that contains e-mail addresses:\n\t{0}", settings.getAddressFieldName()));
        System.out.println(MessageFormat.format("Active record:\n\t{0}", settings.getActiveRecord()));
        
        Odso odso = settings.getOdso();
        
        System.out.println(MessageFormat.format("File will connect to data source located in:\n\t\"{0}\"", odso.getDataSource()));
        System.out.println(MessageFormat.format("Source type:\n\t{0}", odso.getDataSourceType()));
        System.out.println(MessageFormat.format("UDL connection string:\n\t{0}", odso.getUdlConnectString()));
        System.out.println(MessageFormat.format("Table:\n\t{0}", odso.getTableName()));
        System.out.println(MessageFormat.format("Query:\n\t{0}", doc.getMailMergeSettings().getQuery()));
        
        // We can clear the settings, which will take place during saving
        settings.clear();
        
        doc.save(getArtifactsDir() + "Document.OdsoEmail.docx");
      • deepClone

        public MailMergeSettings deepClone()
        Returns a deep clone of this object.

        Example:

        Shows how to execute an Office Data Source Object mail merge with MailMergeSettings.
        // We'll create a simple document that will act as a destination for mail merge data
        Document doc = new Document();
        DocumentBuilder builder = new DocumentBuilder(doc);
        
        builder.write("Dear ");
        builder.insertField("MERGEFIELD FirstName", "<FirstName>");
        builder.write(" ");
        builder.insertField("MERGEFIELD LastName", "<LastName>");
        builder.writeln(": ");
        builder.insertField("MERGEFIELD Message", "<Message>");
        
        // Also we'll need a data source, in this case it will be an ASCII text file
        // We can use any character we want as a delimiter, in this case we'll choose '|'
        // The delimiter character is selected in the ODSO settings of mail merge settings
        String[] lines = {"FirstName|LastName|Message",
                "John|Doe|Hello! This message was created with Aspose Words mail merge."};
        
        String dataSrcFilename = getArtifactsDir() + "Document.MailMergeSettings.DataSource.txt";
        Files.write(Paths.get(dataSrcFilename),
                (lines + System.lineSeparator()).getBytes(UTF_8),
                new StandardOpenOption[]{StandardOpenOption.CREATE, StandardOpenOption.APPEND});
        
        // Set the data source, query and other things
        MailMergeSettings settings = doc.getMailMergeSettings();
        settings.setMainDocumentType(MailMergeMainDocumentType.MAILING_LABELS);
        settings.setCheckErrors(MailMergeCheckErrors.SIMULATE);
        settings.setDataType(MailMergeDataType.NATIVE);
        settings.setDataSource(dataSrcFilename);
        settings.setQuery("SELECT * FROM " + doc.getMailMergeSettings().getDataSource());
        settings.setLinkToQuery(true);
        settings.setViewMergedData(true);
        
        Assert.assertEquals(settings.getDestination(), MailMergeDestination.DEFAULT);
        Assert.assertFalse(settings.getDoNotSupressBlankLines());
        
        // Office Data Source Object settings
        Odso odso = settings.getOdso();
        odso.setDataSource(dataSrcFilename);
        odso.setDataSourceType(OdsoDataSourceType.TEXT);
        odso.setColumnDelimiter('|');
        odso.setFirstRowContainsColumnNames(true);
        
        // ODSO/MailMergeSettings objects can also be cloned
        Assert.assertNotSame(odso, odso.deepClone());
        Assert.assertNotSame(settings, settings.deepClone());
        
        // The mail merge will be performed when this document is opened
        doc.save(getArtifactsDir() + "Document.MailMergeSettings.docx");