Mail Merge and more…

Hope you are having fun with enhanced mail merge functionality in Titan and others in general. In this article I would like to touch on a number of topics about mail merge support in Microsoft Dynamics CRM 4.0.

a) Many faces of mail merge.

b) Mail merge experience in different clients and modes.

c) Configuring web mail merge support in CRM.

d) Configuring mail merge support for entities.

e) Emailing to custom and non primary email address via mail merge

a) Many faces of mail merge.

Mail merge functionality can be assessed from different places; you might be amazed on how many code paths lead into mail merge.


Mail Merge from grid.

Mail merge in this case is called by clicking the mail merge icon on the grid. Along with other options, it gives users an option to run mail merge on selected records, records on the current page or on the current view. Mail merge from grid is available for all mail merge enabled entities. By default account, contacts, leads, opportunities and all custom entities are mail merge enabled.


Mail Merge from Advance find and sub grids.

Mail merge functionality can be invoked for mail merge enabled entities from the advance find dialog and the related entity sub grids shown on the entity detail page.


Mail Merge from entity detail page.

Mail merge functionality can be invoked from the actions menu on the entity detail page of the mail merge enabled system entities. Like account, contact and lead.


Mail Merge for marketing list.

Mail merge functionality here can be invoked from the marketing list detail page and will run on the members associated with that list.


Mail Merge for Campaign activity.

Mail merge functionality here can is invoked by clicking the distribute button on the campaign activity detail page, when the channel type is set to distribute via mail merge. The records participating in the mail merge are the members associated with the campaign activity. Campaign activity contains marketing lists and the marketing lists in turn lists the members (account, contact or lead). For distribution of campaign activity via mail merge the member type of all associated marketing list needs to be same.

Note: this feature is available only from CRM online outlook client.


Print quote for customer.

This is a special feature where users can generate summary document containing all quote product associated with the quote. The functionality is invoked from the quote detail page.


Mail Merge vs. quick campaign.

In titan, users can create quick campaign when running mail merge and tracking output in CRM. The usefulness of tracking a mail merge via quick campaign is that it gives them a single location of viewing all the records that were generated. It lists the records that participated in the mail merge and records that were excluded from the mail merge due to privacy conditions or failure. Also note that users can access mail merge functionally from within create quick campaign wizard and have the same results.

Note: this feature is available only from CRM online outlook client.

From mail merge tracking dialog.


From quick campaign wizard.


Mail Merge Template detail form.

A variation of the mail merge functionality is also exposed from the mail merge template detail form. The goal here is to assist user is creating and editing mail merge templates. The functionality is invoked by clicking the “Create template in word“ or “Edit template in word” button.



b) Mail merge experience in different clients and modes.

The mail merge behavior varies depending on the client the user is using to invoke mail merge. When in web client, the mail merge is enabled by using signed macros and associated templates. For outlook client the CRM addin loaded inside outlook, handles the mail merge invocation. Web mail merge makes the functionality more available to the user as it requires no client bit installations, where as outlook client gives enhanced functionality like the auto tracking of generated items and upload template to CRM.

Also there are differences in behavior when using mail merge in CRM outlook online mode verses offline mode. Some features like Campaign activity distribution and creating quick campaigns from mail merge are only available when in online mode.

c) Configuring web mail merge support in CRM.

– Web mail merge is a powerful feature for you when you are trying to quickly print out some letters for a set of customers or email them. This does not require your to be logged inside outlook or running a smart client.

– Via the web the user invokes web mail merge, the user is provided with a document with the template they have chosen and data source. With a click of button they are inside mail merge and running it.

– The web mail merge uses Word VBA support of macros to enable the seamless integration. The macro is Microsoft signed content and it is delivered inside the document via the CRM Template located on the server.

– Some times businesses have a no macro use policy and would like to disable the web mail merge functionality. For such cases, there is a new miscellaneous privilege “Web mail merge” that can be used to disable web mail merge for users.


d) Configuring mail merge support for entities.

– Mail merge support for an entity is driven by the entity metadata field “IsMailMergeEnabled”.

– For custom entities mail merge is enabled by default. It’s less known that this setting is actually configurable. There is no UI to enable or disabled this setting from the customizations area. But via the SDK or customization import, users with system administrator role or system customize role can reset it.

– For system entities its only enabled for Account, contact, lead and opportunity. This field is not configurable via the SDK or customization import.

– Steps to flip the mail merge support for a custom entity via SDK

  • Create a console application in VS.
  • Add a metadata web reference to it.
  • Web reference Url would be some thing like: http://[serverName:portNumber]/mscrmservices/2007/MetadataService.asmx
  • Add the following code and execute.

using MetadataSDK = /* your metadata web reference.*/;

public static void Main(string[] args)




// Create Metadata service.

MetadataSDK.MetadataService svc = new MetadataSDK.MetadataService();

svc.Credentials = System.Net.CredentialCache.DefaultNetworkCredentials;

svc.Timeout = -1;

svc.CrmAuthenticationTokenValue = new MetadataSDK.CrmAuthenticationToken();

svc.CrmAuthenticationTokenValue.OrganizationName = “OrgName”; // Your organization name.

// Create retrieve entity request.

MetadataSDK.RetrieveEntityRequest request = new MetadataSDK.RetrieveEntityRequest();

request.LogicalName = “new_mycustomentity”; // Custom entity name.

request.EntityItems = MetadataSDK.EntityItems.EntityOnly;

MetadataSDK.RetrieveEntityResponse response = (MetadataSDK.RetrieveEntityResponse)svc.Execute(request);

// Log.

Console.WriteLine(“IsMailMergeEnabled = ” + response.EntityMetadata.IsMailMergeEnabled.Value);

// Flip the mail merge support for that entity.

MetadataSDK.EntityMetadata entity = new MetadataSDK.EntityMetadata();

entity.MetadataId = response.EntityMetadata.MetadataId;

entity.IsMailMergeEnabled = new MetadataSDK.CrmBoolean();

entity.IsMailMergeEnabled.Value = !response.EntityMetadata.IsMailMergeEnabled.Value;

// Execute request.

MetadataSDK.UpdateEntityRequest request1 = new MetadataSDK.UpdateEntityRequest();

request1.Entity = entity;


// Confirm results.

MetadataSDK.RetrieveEntityResponse response1 = (MetadataSDK.RetrieveEntityResponse)svc.Execute(request);

// Log.

Console.WriteLine(“IsMailMergeEnabled = ” + response1.EntityMetadata.IsMailMergeEnabled.Value);


catch (Exception e)





– If you are new to SDK and uncomfortable using it, you can use an alternative method for resetting this field via import/export customization.

  • Export out the customizations for the custom entity for which you intend to switch the mail merge support off.
  • The customization are exported to a file like
  • Open the zip file and extract the customization.xml present inside it.
  • Update the “IsMailMergeEnabled” node value from 1 to 0
  • i.e. <IsMailMergeEnabled>0</IsMailMergeEnabled>
  • Next, import the updated customization.xml file back into CRM via import customizations.
  • Publish the custom entity after import.
  • The mail merge support for that entity will be switched off now. I.e. no mail merge icon will show up on that custom entity grid.

e) Emailing to custom and non primary email address via mail merge.

Consider the following scenarios:

1) You have a set of entities say account where there are two email addresses present on it. You wish to send emails to the secondary field (emailaddress2) and not the primary email address (emailaddress1). Currently CRM does not allow you to do that.

2) You have created a custom field on opportunity to store opportunity’s email address. Currently CRM does not allow you to send email to opportunity.

3) You have created a custom entity with a custom field name new_email. CRM does not allow you to create email and send them to these custom email fields.

In all the above scenarios, mail merge can help. You can run mail merge on the selected entities and select the merge type as e-mail. Then, when invoked for message options inside word, as shown in the image below, select the custom field containing the email address as the “To” field. Proceed with your mail merge.


When in CRM outlook client, you would be able to track these emails in CRM as regular email activities with appropriate regarding object set. Note: The “To” field of the email record created in CRM will be left unresolved. Few more things to know when doing it are:

a. If you have the same email address on other records like account, contact, lead, system user or queue. The “To” field will get resolved to those records.

b. If you have replies coming back for the email you sent via above method, And these received emails getting tracked in CRM, the recipient will not get resolved correctly. But hey, the regarding object will get resolved correctly due to the presence of tracking token. So you should have a functional system.