title: Aspose.Words - MailMerge images
body: <p>I am trying to loop through a <code>Dataset</code>, creating a page per item using Aspose.Words Mail-Merge functionality. The below code is looping through a <code>Dataset</code> - and passing some values to the Mail-Merge Execute function.</p>
  
  <pre><code>var blankDocument = new Document();
  var pageDocument = new Document(sFilename);
  ...
  foreach (DataRow row in ds.Tables[0].Rows){
      var sBarCode = row["BarCode"].ToString();
      var imageFilePath = HttpContext.Current.Server.MapPath("\\_temp\\") + sBarCode + ".png";
  
      var tempDoc = (Document)pageDocument.Clone(true);
  
      var fieldNames = new string[] { "Test", "Barcode" };
      var fieldData = new object[] { imageFilePath, imageFilePath };
  
      tempDoc.MailMerge.Execute(fieldNames, fieldData);
  
      blankDocument.AppendDocument(tempDoc, ImportFormatMode.KeepSourceFormatting);
  }
  var stream = new MemoryStream();
  blankDocument.Save(stream, SaveFormat.Docx);
  // I then output this stream using headers, 
  // to cause the browser to download the document.
  </code></pre>
  
  <p>The mail merge item <code>{ MERGEFIELD Test }</code> gets the correct data from the <code>Dataset</code>. However the actual image displays page 1's image on all pages using: </p>
  
  <pre><code>{ INCLUDEPICTURE "{MERGEFIELD Barcode }" \* MERGEFORMAT \d }
  </code></pre>
  
  <p>Say this is my data for the "Barcode" field:</p>
  
  <pre><code>c:\img1.png
  c:\img2.png
  c:\img3.png
  </code></pre>
  
  <p>Page one of this document, displays <code>c:\img1.png</code> in text for the "Test" field.  And the image that is show, is <code>img1.png</code>.  </p>
  
  <p>However Page 2 shows <code>c:\img2.png</code> as the text, but displays <code>img1.png</code> as the actual image.</p>
  
  <p>Does anyone have any insight on this?</p>
  
  <p>Edit: It seems as this is more of a Word issue.  When I toggle between <kbd>Alt</kbd>+<kbd>F9</kbd> modes inside Word, the image actually displays <code>c:\img1.png</code> as the source.  So that would be why it is being displayed on every page.</p>
  
  <p>I've simplified it to: </p>
  
  <pre><code>{ INCLUDEPICTURE "{MERGEFIELD Barcode }" \d }
  </code></pre>
  
  <p>Also, added test data for this field inside Word's Mailings Recipient List.  When I preview, it doesn't pull in the data, changing the image. So, this is the root problem.</p>