How to Apply Custom Formatting during Mail Merge
The MailMerge class provides two events that could be very useful in expanding Mail Merge capabilities. The setFieldMergingCallback(IFieldMergingCallback) property accepts a class which implements the methods fieldMerging(FieldMergingArgs) and imageFieldMerging(ImageFieldMergingArgs). These can be used to implement custom control over the Mail Merge process.
The fieldMerging(FieldMergingArgs) event occurs during Mail Merge when a simple Mail Merge field is encountered in the document. This gives further control over the Mail Merge and you can perform any actions when the event occurs. This method is wrapped in a class that implements the IFieldMergingCallBack interface and accepts a FieldMergingArgs object that provides data for the corresponding event.
The code example given below demonstrates how to implement custom logic in the MergeField
event to apply cell formatting.