Issue with AppendDocument()

Hello there,

I am running mail merge repeatedly for the same document and at the end I am just appending to get the final output.
Here is my code snippet:

Document objMailMergeDocument;
foreach (Client objClient in clientList)
{
    mmDataSource = GetPropertyMailMergeDataSource(objClient, mergeFields);
    objMailMergeDocument = objReportDocument.Clone(); //objReportDocument contains all merge fields
    objMailMergeDocument.MailMerge.MergeField += new MergeFieldEventHandler(MailMerge_MergeField);
    objMailMergeDocument.MailMerge.MergeImageField += new MergeImageFieldEventHandler(MailMerge_MergeImageField);
    objMailMergeDocument.MailMerge.Execute(mmDataSource);

    // Mail Merge Second Pass
    objMailMergeDocument = ExecuteMailMergeSecondPass(objMailMergeDocument);

    emailTo = objClient.EmailAddress.Address;
    if (!string.IsNullOrEmpty(emailTo))
    {
        if (emailReports.Keys.Contains(emailTo))
        {
            emailReports[emailTo].Add(objMailMergeDocument);
        }
        else
        {
            List reports = new List();
            reports.Add(objMailMergeDocument);
            emailReports.Add(emailTo, reports);
        }
    }
}
EmailUtility objEmailUtility = new EmailUtility(objReportRequest);
objEmailUtility.EmailReport(emailReports);

objReportDocument.RemoveAllChildren();
foreach (KeyValuePair<string, List> emailReport in emailReports)
{
    foreach (Document objReport in emailReport.Value)
        objReportDocument.AppendDocument(objReport, ImportFormatMode.KeepSourceFormatting);
}

But when I am calling AppendDocument, it just hangs on after iteration and throws error after 5-6 mins:
"Exception of type ‘System.OutOfMemoryException’ was thrown."

FYI, Individual document that I was testing with - each contains 18 pages.
Is there any maximum no. of pages that an Aspose document can hold?

Hi Nutan,

Thanks for your request. There is no limit of number of pages or document size. But you should note, when you open document using Aspose.Words, document object model is built in the memory. DOM always takes few times more memory that the original document size.
So maybe your document is too huge. I think, in your case, it is better to use few smaller documents instead of one huge document.
Best regards,