Free Support Forum -

Accessing the datasource from within the FieldMerging callback

This is a two part question regarding the Mail Merge functionality.

First, what are the available field prefixes? I know about the TableStart/End and Image prefixes. Are there any others? I can't find anywhere that they are listed.

Next I'm needing access to the datasource inside the FieldMerging callback event. I'm getting a date value from the datasource but I need to be able to specify the format within the document template. My plan was to use a merge field in the format of {{Date:d_MMMM_yyyy:date_field}}. Then inside the FieldMerging callback extract the date format and field name from the e.DocumentFieldName property and format the value. My problem is getting the raw date value. I don't see a way to access the current table to pull the date value out of it. Any help would be greatly appreciated.


Thanks for your inquiry. Yes, there is no other prefix except TableStart/End and Image prefixes while creating a Mail Merge template document.

Unfortunately, I have not completely understood your query. As per my understanding, you want to access Data Source inside FieldMerging. Please check the following code snippet for your kind reference.

Hope this answers your query. If this does not help you, please share some more detail about your query along with input document and your expected output document. We will then provide you more information on this along with code.

Document doc = new
Document(MyDir + “in.docx”);<o:p></o:p>

DataTable dt = new DataTable("Test");

dt.Columns.Add("ID", typeof(int));

dt.Columns.Add("value", typeof(string));

dt.Rows.Add(1, "value1");

// Set up the event handler for image fields.

doc.MailMerge.FieldMergingCallback = new MailMerge_Test(dt);


public class MailMerge_Test : IFieldMergingCallback


DataTable data;

public MailMerge_Test(DataTable dt)


data = dt;


void IFieldMergingCallback.FieldMerging(FieldMergingArgs args)


if (args.FieldName == "Test")


// Your code to work with DataTable data.



void IFieldMergingCallback.ImageFieldMerging(ImageFieldMergingArgs e)