The problem was that we have multiple queues with email addresses in crm 2011. When an email arrives it goes to a particular queue depending on the address that was used. Now what happens when you try to reply to that email? Well nothing much only that the "FROM address" lookup defaults to the currently logged on user instead of defaulting to the queue's email address.
There are various ways you can solve this issue by writing plugin or workflow custom activity etc, but the crux of the matter is that the crm user replying from a queue needs to the see what the from email address is.
This can be best achieved by using Java script.
Please note that the code below is an unsupported customization, but it works.
There are various ways you can solve this issue by writing plugin or workflow custom activity etc, but the crux of the matter is that the crm user replying from a queue needs to the see what the from email address is.
This can be best achieved by using Java script.
Please note that the code below is an unsupported customization, but it works.
function CheckEnquiryReplyAddress() { // Only complete this validate on Create Form var formType = Xrm.Page.ui.getFormType(); var emailStatus = GetAttributeValue("statecode"); var emailDirection = GetAttributeValue("directioncode"); if (formType == 1 || (formType == 2 && emailStatus == "Open")) { if (emailDirection == "1"){ var previousEmailId=getExtraqsParam("_InReplyToId", window.parent.location.search); //getting context from the parent window var context = Xrm.Page.context; try { var serverUrl = context.getServerUrl(); //The XRM OData end-point var ODATA_ENDPOINT = "/XRMServices/2011/OrganizationData.svc"; var query="/EmailSet?$select=ActivityId,ActivityTypeCode,DirectionCode,"; query=query+"ToRecipients,Email_QueueItem/QueueId&$expand=Email_QueueItem&$filter=ActivityId eq guid'" + previousEmailId +"'"; query =serverUrl+ODATA_ENDPOINT+ query; var request= new XMLHttpRequest(); request.open("GET", query, false); request.setRequestHeader("Accept", "application/json"); request.setRequestHeader("Content-Type", "application/json; charset=utf-8"); request.onreadystatechange=function(){ CompleteEnquiryReplyCheck(request,serverUrl);} request.send(null); } catch(e) { alert(e.Description); } } } } function CompleteEnquiryReplyCheck(request,url) { if (request.readyState==4) { if(request.status==200) { var queue=JSON.parse(request.responseText).d.results[0]; if (queue != null) { var queueId = queue.Email_QueueItem.results[0].QueueId.Id; var lookup = new Array(); var lookupItem = new Object(); lookupItem.id = queueId; lookupItem.name = queue.Email_QueueItem.results[0].QueueId.Name; lookupItem.typename = "queue"; lookup[0] = lookupItem; Xrm.Page.getAttribute("from").setValue(lookup); } } } }The key here is the _InReplyToId query string parameter from here we are able to query the oData service and get the "To" email address of the original email and then it is simply a matter of putting the "To" address in the "From" lookup. Also note that I am checking that this is an outgoing email. Find the code for getExtraqsParam here. Happy Crming!.