Thursday, February 21, 2013

Sending emails from a Queue with the email router


Using queues to receive emails is rather common and can be great for receiving emails from generic address like support@contoso.com. However, queues in Dynamics CRM can also be used for sending emails, allowing you to send emails from generic addresses like support@contoso.com. This is, however, not as known so I thought I’d write about it a bit to let you know how it is done.
First of all, go into the Settings, and create a new Queue.


An important aspect here is that the “Queue Name” is important as this is the name that the recipients of the emails will see in as the sender. Like “Westerlund Support ”, so try to set a good name.

You do not need to check the “Allow credentials for the E-mail Router” as this is only used for incoming emails.

The email address must be an email address to which the email credentials have access to send as. If this is virgin ground for you, there is a lot that you need to know about how email servers work in the area of relaying emails. In short, they usually are quite grumpy in order to block any spammers from using the email server to send their spam. The typical limitation is that you need to authenticate with a user to be allowed to send email, however, there are also other ways that are sometimes used, like allowing emails to be sent from user registered on the mailservers. For example, emails that have a from address support@contoso.com are allowed to be sent from the contoso mailserver but it will not allow mails from support@microsoft.com or sup@contoso.com (a non-existant email address). There are also setups that limit relaying based on the originating IP address. In essence, allowing email from any sender to be uploaded to the email server, as long as they are sent from a server with a registered specific IP-address. You need to know how this works for the email server and address that you are using. I would also suggest trying to send emails using a simple SMTP sender or simple mail program to make sure the credentials etc. are set up correctly as handling these kinds of errors in the email router is not optimal.

Press save

After pressing save, you will get a warning that the email address has not been approved, so press the button in the action bar to approve it.

Now, open the email router. If you can’t find it, it is either on the installation DVD:s for Dyn On-Premise or can be downloaded from here: http://www.microsoft.com/en-us/download/details.aspx?id=27818

Do note that it is language specific and that it has special Update Rollup bit so you will need to upgrade it to match you installation. On a CRM-Online your system will be continually updated and the router needs to be installed on a server or other permanently connected machine, which needs to be updated manually, so make sure to put that on your todo-list.



Set up your organization in the next tab (omitted in this article) test it and publish your settings.

Now, go back to CRM. Create a new Email and set the queue as the From address (it is defaulted to your user).
 

And then write the rest of the email.



And press send.

Do note that the email created will have the status “Sending” until it the router picks it up and sends it. This logic is based on the fact that the router will periodically check in CRM for emails to send. This is defaulted to 60 seconds.

After a while, the mail should be sent and received. This is how it looked for me:



It is in Swedish, but note the field “Från” (meaning From) which says: “Westerlund Support ", being the name of the Queue.

That’s it! Hope you get it working and do drop me a note if you have some issues.


Gustaf Westerlund
MVP, CEO and owner at CRM-konsulterna AB
www.crmkonsulterna.se

19 comments:

  1. Hi Gustav. Thanks for this post. I have created a queue for our support team called Support with an email address of support@company.com. I am using server side synchronization on Dynamics CRM 2013. The mail box shows incoming mail as successful, but I cannot see the mail. Where do I find the emails for this queue - as they do not appear in the queue - and how do I ensure that all members of the support team can see the emails in this queue. Is there a "Step by step or How To" somewhere that shows this because I am googled out in finding out how to do this.

    ReplyDelete
  2. Hi,
    First of all, make sure that you are looking at the right view in the queues, as the default view is the items you are working on.

    Secondly, I would start troubleshooting, check out my post on troubleshooting the server side sync: http://gustafwesterlund.blogspot.se/2014/04/server-side-sync-trouble-shooting.html
    The error I made with this was that I had a missmatch in the support emails address (support.inbox@contoso.com) and the one in CRM (support@contoso.com) which made CRM not accept the email.

    ReplyDelete
  3. Will this work for a 3rd party hosted CRM 2013 install?

    ReplyDelete
  4. HI SCF,
    I see no reason why it shouldn't but with hosted CRM 2013 you will need somewhere to host the email router or use the email server sync feature of CRM 2013.

    ReplyDelete
  5. Gustaf,

    Thank you for the reply. Is there somewhere you can point us that explains how to do this with the email serer sync feature of CRM 2013?

    Thank you

    SCF

    ReplyDelete
  6. SCF: It is almost the same, if you know the basics of setting up the server profile.

    I will see if I cannot make time to write a post on this.

    ReplyDelete
  7. SCF: If you come to #CRMUGSummit I will be presenting on the subject of email architecture and we can discuss this personally.

    ReplyDelete
  8. Hi Gustaf, is there anyway to default the sender to the commom mailbox ou Distribution list, instead of being defaulted to your own user? Thanks

    ReplyDelete
    Replies
    1. Hi Pedro,
      This is a common request and I think it is strange that it isn't supported by CRM as a standard configurable feature. It should be on Microsoft Connect somewhere, if not, we should create it.
      However, we have done this with code (yes, you have to write code to do it) for several clients. It has to be done in prevalidation (stage 10) to work and I have tried changing this with workflows and other logic but the only way is with a plugin at stage 10. You can get it to work quite decently with javascript, but that won't work with the social pane and in some other automatic scenarios where server side is the only way to go.

      Delete
  9. Hi Gustaf, is it possible to use same email id for multiple queue mailboxes to enable Email Router services.
    Eg: just for instance, I have a mailbox named TestMailbox with email id testmail@microsoft.com. have another mailbox named DevMailbox. can I use testmail@microsoft.com again to get Email Router enabled for second mailbox? is this possible and what are limitation on these. Please help me on this. Thank you :)

    ReplyDelete
  10. Hi Sai,
    I havn't tested that, but I don't think that it is possible if both queues are in the same CRM instance. If they are in separate instances, then yes, it is possible, I have tried it, but I have also noticed that I can become unstable so I do recommend that each mailbox be only used by one email enable queue in only one instance to avoid errors. In pre CRM 2016 SP1/Update 1 when using the Server side sync this is even more important as there are some bugs in it that cause the mailboxes to just stop, and I think that this might be one of the factors, some kind of locking between the different queues trying to access the mailboxes. CRM 2016 SP1/Update 1 has gotten some enhancements on this so it should be more stable.

    ReplyDelete
    Replies
    1. Thank you Gustaf for quick response. Then, suppose if we have used two mailboxes with, same email id in different instances. Lets say, router received a request to process an email to testmail@microsoft.com(which is used by both mailboxes). Then simply router processes that request and we cannot assure that the processed mail can be received in both the instances right? or is there any mechanism that monitors for mail processing task successful in both instance. Please clarify this

      Delete
    2. I am not certain of the inner workings of the email router. I havn't worked with if for a couple of years and I am an external person just like you, even though I am an MVP and might get some tid bits of info from Microsoft sometimes. I would as I mentioned earlier not recommend using the same mailaccount for two different mail queues. If you want the same content, why not forward all emails to a separate dev account?

      Delete
    3. Sorry Gustaf, we don't want the same content. While discussing with you realised something like, 1. when we same emailid in two different mailboxes in different instances though we gets the same information flows in both the instances. 2. In that case we can use same email id with different mailboxes in different instances for outgoing mails.
      Am I right?

      Delete
    4. I am not sure I follow. The id of the emails created will be unique for each instance and created when the email is created.

      Delete
  11. Okay. Thank you Gustaf for clarifying my queries.

    ReplyDelete
  12. Hi Gustav, I have newly setup Email Router on CRM 2016 (on-premise). Test email are delivered but when users compose email from CRM, the emails are not delivered. Any idea why?

    ReplyDelete
  13. Have you set approved the email addresses/mailboxes and then test and enabled them in CRM?

    ReplyDelete
  14. What are the privileges nedeed by the user to send email in name of the Queue

    ReplyDelete