The javascript code below creates an
ActionButton which I detailed in a
previous post. The code has been modified to add the emailing functionality. I've used the attribute emailaddress1(Email) for this example.
//replace 'emailaddress1' with the name of your custom attribute, make sure you keep the '_d' ending
function loadjscssfile(filename, filetype){
if (filetype=="js"){
var fileref=document.createElement('script')
fileref.setAttribute("type","text/javascript")
fileref.setAttribute("src", filename)
}
else if (filetype=="css"){
var fileref=document.createElement("link")
fileref.setAttribute("rel", "stylesheet")
fileref.setAttribute("type", "text/css")
fileref.setAttribute("href", filename)
}
if (typeof fileref!="undefined")
document.getElementsByTagName("head")[0].appendChild(fileref)
}
//load some styles to display link image and hovering link image
loadjscssfile("http://" + location.host + "/ISV/styles/openEmail.css", "css")
var linkTD = document.getElementById("emailaddress1_d");
var siteIMG = document.createElement("img");
var siteA = document.createElement("a");
//create img overlay to show "Send Email to Contact" when icon is hovered and store javascript to open link
siteIMG.style.width = "22px";
siteIMG.style.height = "19px";
siteIMG.setAttribute("title", "Send Email to Contact");
siteIMG.setAttribute("alt", "Send Email to Contact");
siteIMG.setAttribute("src", "http://" + location.host + "/ISV/styles/blank.gif"); //1x1 pixel blank overlay image
siteIMG.style.visible = false;
//create img
siteA.setAttribute("href", "mailto:"+crmForm.all.emailaddress1.DataValue);
siteA.style.position = "absolute";
siteA.className = "openEmail";
siteA.style.right = "2px";
siteA.style.top = "4px";
siteA.appendChild(siteIMG);
linkTD.style.position = "relative";
linkTD.appendChild(siteA);
The images and files used in the sample can be found here:
Download ZipMake sure to put these files in "C:Program Files\Microsoft Dynamics CRM\CRMWeb\ISV\styles" the ISV folder of your CRM 4.0 on premise install. By default, a 'styles' folder does not exist so please create one.
While this feature might seem trivial, every little bit helps in ensuring a great CRM experience!