Yes, I said Email Router. And no, I’m mostly not crazy – I just had a very specific need to fulfill and I didn’t wish to install the standard CRM Email Router to solve a problem.
A Bit of Background
In the next few weeks, sometime before Convergence 2010, I’ll be launching a new online training service for CRM users. This is a totally Online-based solution using the Microsoft Online stack including:
- CRM Online
- Business Productivity Online Suite ( BPOS )
- Windows Azure
The only drawback to using CRM Online is you must install the CRM Email Router on a computer somewhere to move email into and out of CRM Online. Since I wanted everything in a data center not run by me, I decided to spend a little time and effort to create a very simplistic replacement for the Email Router.
Email Router Architecture
At its heart, the Email Router really only does two things:
- Check CRM for unsent messages, sending any it finds
- Check a mailbox for new messages, retrieving and inserting into CRM any it finds
That didn’t seem to be too hard of a process to replicate especially since, in all reality, I only had one CRM user to monitor.
To help me send and receive email, I selected the Chilkat Email .NET Component. It’s quite affordable and has a whole host of useful features.
Everything else was written using the CRM SDK.
The code resides inside a Windows Azure Worker Role and I poll CRM and the Exchange Online mailbox a few times a minute ( again, this is not a high-production environment ).
So how do you determine what email needs to get sent? It’s pretty simple actually: You just query the Email entity and look for emails with a statuscode attribute for a value of 6, which is PendingSend.
Again, I don’t have complicated requirements so I’m only interested in retrieving the TO, Subject, and Description from the email. If my needs develop, I can always add additional functionality to handle scenarios like:
- Multiple recipients
- Multiple users ( From address )
Once I have collected all of the emails to be sent, I connect to Exchange Online, send the emails, then set the status of the email to Sent
Collecting incoming email is a very similar process. Here’s how it works:
- I connect to my Exchange Online mailbox using POP3 and retrieve all of the unread email.
- Looping through each email, I use the SDK method, DeliverIncomingEmailRequest, to actually deliver the email to CRM.
- After successful delivery, I delete the email from the Exchange Online mailbox.
Well, that’s about it. Like I mentioned numerous times: my needs were very simplistic, but as you can see, it’s not rocket science, and the process can be enhanced and extended to suit your needs.