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:

  1. Check CRM for unsent messages, sending any it finds
  2. 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.

 

Software Components

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 ).

 

Sending Email

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
  • Attachments
  • 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

Receiving Email

Collecting incoming email is a very similar process.  Here’s how it works:

  1. I connect to my Exchange Online mailbox using POP3 and retrieve all of the unread email.
  2. Looping through each email, I use the SDK method, DeliverIncomingEmailRequest, to actually deliver the email to CRM.
  3. After successful delivery, I delete the email from the Exchange Online mailbox.

Conclusion

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.

Trackback

2 comments untill now

  1. Hi,

    Did you actually ever develop this? If so is it a working solution and would you be willing to share or sell the code? We have been having multiple problems with email router not delivering all emails for an abundance of reasons and failing to send some emails with control characters in them.

    Please contact me if you can provide us with the source code for this. If not we'll have to write our own from scratch.

    Thanks in advance.

  2. Mitch Milam @ 2012-07-11 11:51

    Hi Michael. Yes, I did. Unfortunately, I decided not to turn it into a product for various reasons – most of which I can't actually talk about. :)

    Thanks, Mitch

Add your comment now

Sign up for our new KnowledgeBits service and get news, tips and tricks and more, delivered straight to your inbox.