locked
Email Signatures RRS feed

  • Question

  • Hi all,

    Is there a way to add email signatures to emails that are sent from CRM? Is it possible to have the same email signature as I have in outlook?

    Regards,
    Saturday, February 6, 2010 8:59 PM

Answers

  • Hi, Danpri.

    It definitely possible. I've used following approach for one of my customers:
    1. I've added e-mail signature field to systemuser entity and placed it  on separate tab of systemuser entity .
    2. I've opened existing contact and created a sign .
    3. I've added following code to onloadevent handler of e-mail entity form:
    function GetSignature()
    {
    var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    xmlhttp.open("POST", "/mscrmservices/2007/crmservice.asmx", false);
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
    
    var xml = "<?xml version='1.0' encoding='utf-8'?>"+
    "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
    " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
    " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
    GenerateAuthenticationHeader() +
    " <soap:Body>" +
    "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
    "<fetchXml> "+
    "&lt;fetch mapping='logical'&gt; " +
    "&lt;entity name='systemuser'&gt; " +
    "&lt;attribute name='new_signature' /&gt; " +
    "&lt;filter type='and'&gt; " +
    "&lt;condition attribute='systemuserid' operator='eq-userid'/&gt; " +
    "&lt;/filter&gt; " +
    "&lt;/entity&gt; " +
    "&lt;/fetch&gt;"+
    "</fetchXml>"+
    "</Fetch>"+
    "</soap:Body>"+
    "</soap:Envelope>";
    
    xmlhttp.setRequestHeader("Content-Length", xml.length);
    xmlhttp.send(xml);
    
    var resultSet = new String(xmlhttp.responseXml.text);
    
    resultSet.replace('&lt;','<');
    resultSet.replace('&gt;','>');
    
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlDoc.loadXML(resultSet);
    
    var signature = xmlDoc.selectSingleNode("//resultset/result/new_signature");
    
    if (signature)
    return signature.text;
    else
    return "";
    }
    
    function insertSignature()
    {
    var descrFrame = document.getElementById('descriptionIFrame');
    
    if(descrFrame.readyState != 'complete')
    return;
    
    var signature = GetSignature();
    var signParts = signature.split("\n");
    var newHTML = "";
    for (var i=0; i < signParts.length; i++)
    newHTML = newHTML + "<br/><b>" + signParts[i] + "</b>";
    var descrWindow = document.frames['descriptionIFrame'];
    descrWindow.document.body.innerHTML = newHTML;
    }
    
    
    if (crmForm.FormType == 1)
    {
    var descrFrame = document.getElementById('descriptionIFrame');
    descrFrame.attachEvent('onreadystatechange', insertSignature);
    }
    That's all.

    And the result .
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    Saturday, February 6, 2010 9:19 PM
    Moderator
  • What we did was make use of our Exchange mail server, what it does is attach the signature of every outgoing email.

    This means that we didnt have to mess about with getting CRM to do it :)

    Jonathan Nachman MBSP, MCTS

    Microsoft CRM Technical Blog

    Technical CRM Consultant for KMS Software
    Monday, February 8, 2010 2:05 PM

All replies

  • Hi, Danpri.

    It definitely possible. I've used following approach for one of my customers:
    1. I've added e-mail signature field to systemuser entity and placed it  on separate tab of systemuser entity .
    2. I've opened existing contact and created a sign .
    3. I've added following code to onloadevent handler of e-mail entity form:
    function GetSignature()
    {
    var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
    xmlhttp.open("POST", "/mscrmservices/2007/crmservice.asmx", false);
    xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
    
    var xml = "<?xml version='1.0' encoding='utf-8'?>"+
    "<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
    " xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
    " xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
    GenerateAuthenticationHeader() +
    " <soap:Body>" +
    "<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
    "<fetchXml> "+
    "&lt;fetch mapping='logical'&gt; " +
    "&lt;entity name='systemuser'&gt; " +
    "&lt;attribute name='new_signature' /&gt; " +
    "&lt;filter type='and'&gt; " +
    "&lt;condition attribute='systemuserid' operator='eq-userid'/&gt; " +
    "&lt;/filter&gt; " +
    "&lt;/entity&gt; " +
    "&lt;/fetch&gt;"+
    "</fetchXml>"+
    "</Fetch>"+
    "</soap:Body>"+
    "</soap:Envelope>";
    
    xmlhttp.setRequestHeader("Content-Length", xml.length);
    xmlhttp.send(xml);
    
    var resultSet = new String(xmlhttp.responseXml.text);
    
    resultSet.replace('&lt;','<');
    resultSet.replace('&gt;','>');
    
    var xmlDoc=new ActiveXObject("Microsoft.XMLDOM");
    xmlDoc.async=false;
    xmlDoc.loadXML(resultSet);
    
    var signature = xmlDoc.selectSingleNode("//resultset/result/new_signature");
    
    if (signature)
    return signature.text;
    else
    return "";
    }
    
    function insertSignature()
    {
    var descrFrame = document.getElementById('descriptionIFrame');
    
    if(descrFrame.readyState != 'complete')
    return;
    
    var signature = GetSignature();
    var signParts = signature.split("\n");
    var newHTML = "";
    for (var i=0; i < signParts.length; i++)
    newHTML = newHTML + "<br/><b>" + signParts[i] + "</b>";
    var descrWindow = document.frames['descriptionIFrame'];
    descrWindow.document.body.innerHTML = newHTML;
    }
    
    
    if (crmForm.FormType == 1)
    {
    var descrFrame = document.getElementById('descriptionIFrame');
    descrFrame.attachEvent('onreadystatechange', insertSignature);
    }
    That's all.

    And the result .
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    Saturday, February 6, 2010 9:19 PM
    Moderator
  • What if the signature already exists and is an HTML or XHTML file?? can I insert it as a signature??
    Saturday, February 6, 2010 9:46 PM
  • You can try to do it.
    Truth is opened the prepared mind

    My blog (english)
    Мой блог (русскоязычный)free countersLocations of visitors to this page
    Sunday, February 7, 2010 7:30 AM
    Moderator
  • How can I insert the HTML file as a signature??

    Monday, February 8, 2010 1:59 PM
  • What we did was make use of our Exchange mail server, what it does is attach the signature of every outgoing email.

    This means that we didnt have to mess about with getting CRM to do it :)

    Jonathan Nachman MBSP, MCTS

    Microsoft CRM Technical Blog

    Technical CRM Consultant for KMS Software
    Monday, February 8, 2010 2:05 PM
  • So let me understand you.......

    CRM and Exchange are on the same server or what?? What do you mean it attached the signature?? How can this be done??
    Monday, February 8, 2010 2:09 PM
  • Exchange is your mail server, it maybe shared with your crm server.

    few links to how you can configure exchange to add signatures to all outgoing email 



    Hope that helps



    Jonathan Nachman MBSP, MCTS

    Microsoft CRM Technical Blog

    Technical CRM Consultant for KMS Software
    Monday, February 8, 2010 2:18 PM
  • Okay, I decided to tackle the HTML part of the question.
    Nearly identical to Andriy's solutions above, I added a Iframe below the new_signature field (text area).  This is to serve as a Preview to the HTML code that will go into the new_signature field. 

    Put this on the Onload for the User Form.  And add an iframe named Preview below the new_signature field.

    crmForm.all.IFRAME_Preview_d.innerHTML = crmForm.all.new_signature.DataValue

    Publish it all.  Just add HTML code that will need to go into the new_signature field for the user. 

    <span  style="font-weight: bold; font-family: Verdana; font-size: 12pt;">Homer Simpson</span><br />
    <span style="font-family: Tahoma; font-size: 10pt; color: rgb(169, 169, 169);">CRM God</span><br style="color: rgb(169, 169, 169);" />
    <img border="0px" alt="" title="" src="http://www.mvps.org/images/mvpani.gif" style="color: rgb(169, 169, 169);" />

    Now this looks exactly like I want it to look in the iframe preview.  When I used Andriy's code to insert into the email body, it did work.  The only thing that was odd was the extra line inserted between each row. 

    Kinda like this:

    Homer Simpson

    CRM God

    <img>

    When it should look like

    Homer Simpson
    CRM God
    <img>

    Any ideas on what is causing the extra spaces?  But proof in concept, Andriy's code does allow you to insert HTML type signatures into the MSCRM email form.  :)
     
    Sunday, February 28, 2010 8:57 AM
  • Sunday, February 28, 2010 10:25 AM
  • Andrii,

    What "Function" are you using for the onload event in the Email entity?

    Friday, April 20, 2012 6:04 PM