Send mailmerge using dynamic attachments on SalesLogix Web Client
Posted By: nicocrm on July 10th, 2013 in General
No Gravatar

This is a pretty common problem: generate a report, and send it to the customer, giving the user a chance to edit the email before sending it. In the past I have used Outlook automation with success (see Sending an email from Saleslogix (or ASP.NET) for example), but there are a few limitations with this approach: most importantly, the Outlook automation has some security limitations (the users will have to configure their browsers to enable it), and it makes it hard to write a rich email that is easily editable by the customer (basically the text of the email has to be hard-coded in the source code). These can be worked around by using mail merge to send the email. There are a few pros and cons to doing this…


  • No security prompt or special browser configuration for the user
  • Template can be edited by the customer
  • Template can be sent to multiple contacts and include some contact-specific merge fields


  • Require desktop integration to be installed
  • Slower
  • Although the Cc and Bcc fields can be populated with arbitrary email addresses, the main recipient of the email must be a SalesLogix contact
  • Template must be pre-existing in the SalesLogix database – the email text cannot be generated on the fly (this could be a pro as well as a con!)

To send the email, use the following Javascript code:

var mmSvc = GetMailMergeService();
var mmInfo = new mmSvc.MailMergeInformation();
mmInfo.EditAfter = true;
mmInfo.EmailCC = "";
mmInfo.ContactIds = contactIds;   // string with contact ids, separated by commas
mmInfo.TemplatePluginId = "BASELETTERTE";

This sends a basic email. To add an attachment, the data for that attachment must first be saved as a new record in the PLUGINATTACHMENT table. Only DATA, PLUGINATTACHID and FILENAME are required to be populated. Once you have a PluginAttachId value it can be added to the message like this (right before the ExecuteMailMerge call):

mmInfo.AddAttachment(0, "", filename, "", pluginAttachId)

This post is for SalesLogix 7.5.4 but a similar approach works on SalesLogix 8.0.