In this webinar, our experts showcase a variety of demo use cases of how different components of the...
There may be a scenario when working in Dynamics CRM where you want to open an email activity in Outlook, as Outlook provides a richer set of formatting and usability options. Yet, if the email record is created (perhaps automatically) within CRM, you'll want it to stay in CRM. In addition, you'll want an easy way to move it to Outlook and automatically populate the body, subject, and recipients, etc. with data from CRM email activity.
Good news! You can accomplish the this by creating a new JavaScript web resource in CRM which will grab each specific email field value, open a new Outlook email, and populate the fields in the Outlook email.
As a use case, you can add a custom ribbon button called "Send Email to Outlook" on the email activity form. The button will call a JavaScript function which would read the email fields from the current record and pass them along to the function below, which will then open a new Outlook email and populate the fields. You may, in addition, populate additional fields such as From, or BCC, or Priority or even add attachments.
function Email(To, Subject, Body) { try { var theApp = new ActiveXObject("Outlook.Application"); var objNS = theApp.GetNameSpace('MAPI'); // value 0 = MailItem var theMailItem = theApp.CreateItem(0) //Bind the variables with the email theMailItem.to = To; //"Subject"; theMailItem.Subject = Subject; // "Body"; theMailItem.Body = Body; //Show the mail before sending for review purpose theMailItem.display(); //You can directly use the theMailItem.send() function //if you do not want to preview the message first. } catch (err) { alert(err); } }
This solution provides an easy, quick, and efficient way to move the contents of a CRM email activity that is created in CRM to a more user-friendly environment in Outlook.
Note: To open email in Outlook, Outlook needs to be up and running.
Important: As this code utilizes the ActiveXObject, it will only work if using Internet Explorer.
Hope you find this useful. Happy CRM'ing!
I am facing this issue "Automation server can't create object"
Hi - This only works from an IE browser and you need to have outlook installed.
how to resolve formatting issue of email, it is displaying html in the outlook body. how we can convert it into proper formatted text.
Hi - yep - we have a property theMailItem.HTMLBody = xxx which can take in HTML.
Thank you so much Alex
Hi Alex, Can we set email regarding field in the outlook when we open email activity in outlook using ribbon button?
Hi Alex, Can we set email regarding field in the outlook when we open email activity in outlook using ribbon button??
Hi Alex, My code was working fine before, i have fixed all settings in IE too, but now i am getting this error "Error: Automation server can't create object"
Thanks for the post. Do you know if you can set the regardingobjectid of the email message using this method so that it will properly be tracked if they send the message?
Hi Curtis - so since this email will be in outlook it will not have the regarding object id populated. Now if the user has the outlook crm client they can click track in crm OR you can have your system setup for auto tracking.
I have tried to get this to work on CRM 2015 on premise. Not succesfull yet. Does anyone know if this works on CRM 2015 RU 1? Getting this error "Error: Automation server can't create object".
I have tried to put it into a button on the ribbon with the CRM Ribbon Workbench - and as a test to put it in an on-save event. Neither works.
I would love to see an example where emails open in Outlook. Either on premise or CRM Online.
Hi Marianne - were you using IE ? IF so, add your crm's url to your list of trusted sites. Depending on your companies policies we have seen policies that do not allow activeX unless the site is running under trusted or local intranet sites.
I am using IE 11. My CRM URL is in trusted sites.
I am facing this issue "Automation server can't create object"
we are using MS CRM 2015 on-prem.
please help me on this