2008-09-22

Marketing Newsletter Automation for MS Dynamics CRM 4.0 - PART I

I needed to tune up my Dynamics CRM 4.0 in order to achieve a simple marketing newsletter automation feature which should be 

Desired features to overcome MS Dynamics CRM 4.0 limitations: 
  1. HTML free campaign (no need to edit or copy/paste HTML code);
  2. Automatic e-mail sending from Queue;
  3. Automatic handling of bounced e-mails.

So, how did we tackle these challenges?


  1. HTML free campaign

The main idea here was to make it very easy to create e-mail newsletters whithout needing any HTML knowledge. Additional challenge: newsletter images' have to be uploaded to a public web folder due to MS Dynamics CRM 4.0 limitations.

To get rid of HTML code we decided to provide a limited set of templates which our marketing guys will have to use. So we prepared templates with 1,2,3,4 and 6 images/links. On the first  campaign tab we added the Images attribute (1,2,3,4,6). After filling the obligatory campaign fields (or attributes) our users will have to choose the number of images (this will also determine the template). The user has to hit Save before moving on the next customized campaign tab (this tab will use the attribute to display a small preview for the chosen template).

The customized campaign tab looks like this:
The Image Links fields are static fields although they are not really static because you can paste any link you want in there. They will allways be there, that's why I called them static.
The Image File fields are dynamic, which means they depend on the number of Images (attribute) chosen. If you choose 4 images (like I did) you will get 4 fields, if you choose 6 images you will get 6 fields. You can preview the template layout if you look at the image below the Image File fields! Cool isn't it?
How did we manage this dynamic thing? iFrames! Marco developed a nice ASPX web page/application that is called by the CRM iFrame. The ASPX web page/application is context sensitive so it can find out the entity (Campaign) ID by itself. Once knowing that, it reads the Images (attribute) and displays the correct number of Image File fields and the appropriate template layout (jpg file). Attention: these image files are links to local files (*.jpg files). The user will have to Browse (in portuguese Procurar...) in order to add the image to the template.
After filling the links and subject fields you are ready to go. You will not fill the Image File fields just yet. Hit Save and then you'll need to Run Workflow.
  
I have two versions of the same workflow: one in english and the other one in portuguese. Why? Disclaimer information in english and portuguese languages is already built in the workflow/template. After choosing the desired language the workflow will run and it'll fill the Offer field (General Tab) with the HTML!
Where does the HTML code come from? It comes from the workflow steps!
The workflow steps include an IF CONDITION in order to update the Offer field with the correct HTML template (1 image html code, 2 images html code...). This is not very dynamic but it gets the job done! Below you can see that how the workflow updates the Offer field with dynamic content such as {(Image 1 link(Campaign)} and {Campaign Code(Campaign)}-1.jpg. Also note that the image file name is changed to a default name (Campaign Code) and number. It had to be like this because we haven't chosen our images yet. That's next!
Now that we've got HTML code we need to upload (via FTP) the HTML (as a file) and the images to a public web folder. Now is the time to go back to the customized tab and browse for the image files. After you've chosen your image files you can hit the Upload button (it only appears after running the workflow). 
Upload? Yes! Upload via FTP to a public folder with a touch of a button! This was one of the most difficult challenges we faced. We had to embed a FTP client in our web page/app! We were lucky to find the source code for a dot net FTP client after some heavy googling. For me this upload button feature was the cherry on the top of the cake! 
After you're done you'll get a status message and you will be able to verify your newsletter online. If you choose the Click Here to Verify Option a new browser window will open and you'll be taken to your newsletter webpage. Check the 4 image template below (the disclaimer is there but the page is zoomed out so you probably won't notice it)! In case you're wondering the 4 photos were taken at very nice hotel situated in Madeira Island, Portugal.
Now we're ready to spread the newsletter by e-mail. That takes us to my next post and Desired Feature Number 2: Automatic e-mail sending from Queue.


No comments:

Post a Comment