MailMerge produces identical documents with identical addressee

3 posts, 0 answers
  1. Joachim
    Joachim avatar
    2 posts
    Member since:
    Dec 2014

    Posted 19 Jul Link to this post

    Dear support,

    we are facing rather often but nevertheless unpredictably the problem that the mail merge functionality produces identical documents. This is the part of code

    01.public static IList<object> GetMailMergeBinaryResultDocuments
    02.                     (byte[] source, IEnumerable mailMergeDataSource)
    04.  if (mailMergeDataSource == null)
    05.  {
    06.    throw new ArgumentNullException("mailMergeDataSource");
    07.  }
    09.  RadDocument masterDocument = XamlFormatProvider.Import(source);
    10.  masterDocument.MailMergeDataSource.ItemsSource = mailMergeDataSource;
    11.  RadDocumentEditor radDocumentEditor = new RadDocumentEditor(masterDocument);
    13.  radDocumentEditor.ChangeAllFieldsDisplayMode(FieldDisplayMode.Result);
    15.  List<object> resultDocuments = new List<object>();
    16.  masterDocument.MailMergeDataSource.MoveToFirst();
    18.  do
    19.  {
    20.    resultDocuments.Add(masterDocument.MailMergeCurrentRecord());
    21.  }
    22.  while (masterDocument.MailMergeDataSource.MoveToNext());
    24.  return resultDocuments;


    where we know that different mail merge information was passed but for some reason was not processed correctly.

    Can you help?


    Regards   Jo

  2. Boby
    Boby avatar
    588 posts

    Posted 21 Jul Link to this post

    Hi Joachim,

    I was not able to reproduce such issue with the provided code; so maybe the problem lies outside it. Could you open a support ticket and send us sample runnable project that reproduces it? This will help us investigate the issue further. 

    As a side note - on possible problem that may affect you with this method is that 
    MailMergeDataSource.MoveToFirst won't work if the IEnumerable source is not materialized. In this case, invoking ToList on the source will ensure that the the source is prepared for mail merge:
    var enumerable = GetPersons();
    var documents = GetMailMergeBinaryResultDocuments(File.ReadAllBytes(@"c:\temp\xaml.xaml"), enumerable.ToList());
    private IEnumerable<Person> GetPersons()
        yield return new Person() { FirstName = "John", LastName = "Smith" };
        yield return new Person() { FirstName = "Robert", LastName = "Brown" };
        yield return new Person() { FirstName = "James", LastName = "Miller" };

    I am mentioning this as it may be also related to your problem.

    Telerik by Progress
    Do you need help with upgrading your AJAX, WPF or WinForms project? Check the Telerik API Analyzer and share your thoughts.
  3. DevCraft R3 2016 release webinar banner
  4. Joachim
    Joachim avatar
    2 posts
    Member since:
    Dec 2014

    Posted 03 Aug in reply to Boby Link to this post

    Hi Boby,

    unfortunately your suggest did not change anything. I´ll try to build a small application which reproduces the problem. That´ll take some time. Thanks so far.

    Regards  Jo

Back to Top