For the latest updates to this post please visit the original posting here: Open an Email Activity in Outlook from Dynamics CRM
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!
The post Open an Email Activity in Outlook from Dynamics CRM appeared first on PowerObjects.