tisdag 30 april 2013

Email router configuration

The Microsoft Dynamics CRM 2011 Email router is almost an endless source of joy. One of these is to make it work. I wrote this for my own reference since it might be some time between the occations I have to setup an email router. 

The first thing you do is to launch the Email router configuration manager and what greets you is the profile tab. In this tab you set up incoming and outgoing profiles for your deployment(s). There needs to be at least one incoming and one outgoing profile, but in most occations there will be more of these.

To create a profile click the "new" button on the right. Here you have a couple of choices, the first one being to give your profile a name. In this example it will be "incoming" and the profile will be for incoming mail.

Here I have chosen a POP3 email server which gives us a couple of choices to make. One is Authentication type which can be NTML or clear text, I have chosen the latter here. With clear text it's recommended that you use SSL.

Then you just enter the server address and which credentials you want to use, in the case of POP3 you can choose "other specified" and "user specified". In this screen shot the other specified is marked and as you can see the user name i determined by the email address and that the password window is empty. This means that the user or queue you will associate this profile with will have the email address for user name and a password stored in the Email router. This means also that all users and queues using this profile will have to have the same password, which is NOT recommended and thus you need a profile for each user/queue and you need to update that profile each time the user or queue change the password. That is not good in a couple of ways, one being that you will need the password of the user and that's not best practice in any way.

 If you choose another email server type, for example Exchange 2010, you get another set of options. For Exchange Server 2010 the only way to access the server is using the web services which have a URL. This is entered in the location window and looks something like "http://mail.server.com/EWS/Exchange.asmx". In the screen shot I have just changed from POP3 to Exchange 2010.

For cretentials you have the same choices as in the POP3 case, but you can also chose "Local system account". The "other specified" looks a bit different from the POP3 case too. Here you can enter an admin account which has access to the email boxes that you want to use the router for. The same goes for the Local system account. I haven't used any of these in a live system and have been told, rather harshly, by an exchange expert that you don't want to do that. The third choice is user specified. This means that the user enters credentials into the CRM and those are used to access the email box, seems like the best way to handle this if you're using Exchange.
The result looks something like the image to the left. Another thing to think about if you're using Exchange 2007 is that the Webdav protocol doesn't seem to like some characters. We've had the entire router service shut down when an email entered the inbox with a subject containing a character that the email router did not appreciate.


 Now, the next thing we do have a look at is the Advanced tab.
Here we can change the ports we are using to connect to the server, this is definitely needed when changing the protocol to SSL.











 Now that we've done our incoming rule we need an outgoing rule. Again there are a couple of choices needed, the first being the name, next we choose outgoing for direction and in the second drop down we can choose either exchange online or SMTP. For this example SMTP is our choice.

 Then we have the authentication type. The choices being Windows Authentication, clear text and Anonymous. To be able to use credential type "Local system account" you need to use Windows authentication. Again, if you use clear text be sure to use SSL. After you choose authentication type, you need to enter the url to the SMTP server and finaly choose Access credentials.












In the next screen shot I have made my choices, in this case Clear text which only give me the choice of other specified for credentials. As you can see I've entered a username and a password in the credentials input fields. If I would have chosen anonymous, those fields wouldn't be available.
Again, the Exchange expert I was talking to recommended that you did not use anonymous access to the smtp server. Further she didn't like the idea of one user being able to send emails in the name of everybody in an organization. With this info on hand, the outgoing profile is more or less useless for everyone except queues, and even in that case it's quite a lot of job maintaing the system if you have a lot of queues. One thing I fins a bit curious is that you can't have the user specified credentials for outgoing email, that would have solved some problems at least.

If you need to change some port settings, the advanced tab looks roughly the same as the incoming rule advanced tab.




Now you are done with the profiles and you have a profile tab looking something like this.






















Let's move on to the deployment tab. Here you set up wich CRM deployment you want to use. Again click on the "New" button on the right hand side and you get a new window with settings for the deployment.


Here you can choose to use an on-premise CRM, a partner hosted CRM or an on-line CRM. I chose on-premise (My Company) and entered the url for the crm, complete with port and organization name. Then I entered a user after chosing "Other specified" as credential type, the other choice is Local system account. Make sure to use a user with enough rights in the CRM, otherwise it might work in an unexpected way. The last two dropdowns specify if you want to use any profile as default, I chose not to do this.






After that is done we want to link our users and queues to profiles, that is done on the last tab
Here I have already clicked "Load Data" after chosing my deployment from the dropdown. All email router enabled users and queues from the organization are shown and you simply open them and add an incoming and/or outgoing profile to them. After that is done you press the "Test Access" button to se if there are any obvious errors done.



As you can see all data is entered correctly and the test went ok.












Now, this doesn't mean that it will work, this means there are no errors in the setup. And this ends this quick demo of how you set up a email router for CRM 2011, and CRM 4.0 since they differ very little if they do at all.

Hope this helps!

Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se    

torsdag 11 april 2013

The CRM Email router routing emails into unexpected queues.

I've been working with the email router a couple of times the past few weeks and each time is a new bag of funny stuff. This jewel just keeps on giving.

The latest bit of interesting behaviour I found was that when an email is sent to two or more different queues it actually gets queued in all of them. This was a certain blog topic in my little head, but just to be sure about it I did a bit of resarch and found this blog which proved me wrong in my thought that an object only could be present in one queue at a time.


However, there was another thing that caught my interest and that was that a queue that isn't active on the email router can get email into it.


The queue support3 is set up like this in CRM and has no rule on the email router since it's just an alias.


This was a bit curious since I hadn't got an incoming rule set up for the queue. This is not that exact email but I reproduced the behaviour. What happened on the customer's system was that they were re organizing their incoming email and had a bit messy system for it so they forwarded the email from one address to another mailbox and we were polling that mailbox. Now, I tried to set up a queue using the email address that was being forwarded on the emailbox that had another username. This was not so popular with the email router setup so I reverted to the email address that matched the username. In this example it is support2. When I enabled that incoming rule on the email router, emails started coming into the queue of the forwarded email address.


What happened was that the email router polled the incoming box of support2, finding the email addressed to support3, looked the queues and found a match in support3 and delivered the email to support3.


Needless to say, I was a bit confused. I told the customer what just happened and he looked at me asking does the email enter the system and end up in the correct queue? Well, sort of, not the queue we planned it to enter, but the old queue. Fair enough, let it be, it's working.


I don't know if this is the way it's supposed to work but it could be a shortcut getting email into the system using one email box and a heap of aliases. Sort of the forward email box but without having to put the original email into an attachment.


Rickard Norström
Developer at CRM-Konsulterna
www.crmkonsulterna.se