Saturday, October 24, 2009

The troubles of customizing campaign emails

I finally have the time to update this blog again, and I would like to share my experiences with customizing the marketing email functions of MS CRM.

As we all know, sending mass marketing email from MS CRM is a bit of a challenge. The UI is hopeless, and there's no way to do HTML editing, previews, or to incorporate other functionality into the process of sending emails. Sending mass email from MS CRM involves creating a campaign activity, hook it up with marketing lists, and then click the "distribute campaign activity". Contradictory to the title, this function does not distribute the emails, but open up an email activity window. At this stage you have to design your HTML email in another system, save it to disk, open the file in Internet Explorer, select all, copy and paste it into the email activity window. Then you click send, without any possibility of preview or testing.

For professional marketing departments this means running their campaigns over and over again to mock up marketing lists for live testing until they find the results satisfactory. There's no possibility to retrieve a previous sent email, make the necessary changes, and redistribute it. You can use templates, but you can't edit them before sending.

Other systems are designed to use template sets tailored to the individual organisation's needs, and incorporates the process of testing and recycling mass emails. MS CRM is so far behind in this department. On the other hand, selecting members of marketing lists, and the concept of attaching different campaign activities to a campaign, making it possible to distribute a campaign message in different channels, has a lot of potential.

So, the basics of mass emailing in MS CRM is flawed, but there's always the possibility of customizing it, right? Or so I thought...

The first thing I tried was a third - party product which added click-through and HTML editing capabilities. It turned out it was flawed as well. Most importantly it didn't work, and secondly, it used unsupported customizations.

The second thing I tried was customizing the email activity. I added a few fields to do the following: 1) A checkbox to to indicate whether or not this was a test distribution. 2) A hidden ntext field to store the fetchXML of the last email distributed, and 3) A field for hypertext tagging for use by WebTrends or Google Analytics. I then started developing plugins which I registered on the email activity entity to accomodate somthing in the vincinity of the requested functionality.

After working with the plugins it became clear to me how flawed this part of MS CRM actually is. When you click "send" the campaign activity is distributed and the individual emails are created and sent. One should think it was possible to manipulate those emails both on the pre- and poststage in the child pipeline, but unfortunately it isn't.

What actually happens is this: when you click "send" the systems creates a SendBulkEmailRequest object, and attaches an email template to it. Where this email template comes from is unclear, but I suppose it is created temporarly based on the contents of the email activity window. The SendBulkEmailRequest the creates the individual emails, which are all empty in the pre-create execution stage. (The plugin is executed, but the body attribute is empty). They are then "filled" with the contents from the template, and attached to the SendBulkEmailRequest. If you register a plugin on post-stage, the emails contains the contents of the created template, but they are somehow already copied to the request. The plugin may manipulate them, but it has no consequences for the emails actually send.

In other words, it's impossible to create plugins on the email activity for marketing purposes.
Then why not create or register the plugin on the template entity? Somehow it's empty as well in the pre-create stage, and in the post-create stage it's too late. MS CRM reads the contents from the description window directly and somehow bypasses the execution pipeline.

So doing any customization or creating plugins for the template entity is futile as well.

The solution is to create a specialized ASP.NET page which you integrate into MS CRM, and which sends bulk emails through the web services. That way you have complete control with the code and the process - even though it's time-consuming this is generally the best approach