none
[outlook or office 365 outlook] Javascipt not getting run on outlook RRS feed

  • Question

  • Hi

    We have requirement to send the email containing the HTML text having some sort of java script to run.

    We have verified same HTML content getting working on the browser.

    Can anyone one suggest why java script is not working on the outlook.

    Am i supposed to do some settings in outlook get script work.

    For information, we have embedded JavaScript against the button to copy the text to clipboard.

    for reference refer the below HTML:

    <html><body><script src="https://cdn.jsdelivr.net/clipboard.js/1.6.0/clipboard.min.js"></script><script>var clipboard = new Clipboard('.btn');clipboard.on('success', function(e) {console.info('Action:', e.action);console.info('Text:', e.text);console.info('Trigger:', e.trigger);e.clearSelection();});clipboard.on('error', function(e) {console.error('Action:', e.action);console.error('Trigger:', e.trigger);});</script><table border="0" cellpadding="2"><tr><td>Some Sampe Check</td><td><button class="btn" data-clipboard-text="Sample text MAIL for text to copy to clip board">Copy to clipboard</button></td></tr></table></body></html>

    Friday, March 24, 2017 12:30 PM

All replies

  • Hello Aresha,

    What browser did you try for testing the JS code? What Outlook version do you have installed on the machine?

    Old Outlook versions may block any scripts in the message body for security reasons. See Is JavaScript supported in an email message? for more information.

    One possible solution would be to give users a URL to a web page with code behind it to launch the form. If you are working in an Exchange organization and have permission to publish to the Organizational Forms library, you could use VBScript behind a published custom Outlook message form.  


    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Saturday, March 25, 2017 11:55 AM

  • can any one suggest what all setting need to do in order to run the JavaScript within outlook mail. mail body with HTML code mentioned in original thread.

    as requested information about outlook version, I am using the office 365 outlook


    Monday, March 27, 2017 5:07 AM
  • Kindly reply as soon as possible

    Thanks

    Monday, March 27, 2017 1:56 PM
  • Looks like it depends on the Outlook version, not IE settings.  

    profile for Eugene Astafiev at Stack Overflow, Q&A for professional and enthusiast programmers

    Monday, March 27, 2017 3:43 PM
  • Hello Aresha,

    I feel so sorry that it seems I misunderstood your issue. I thought you are developing an Office Add-in and using the HTML code above. Are you developing an Office Add-in with Office JavaScript API?

    If you are inserting the HTML code above as HTMLBody of mail item, it is impossible to run the script as Eugene mentioned.

    You may work around as Eugene suggested to create a custom form. And in my opinion, I would suggest develop Office add-ins using Office JS API. For more information, please visit Overview of Outlook add-ins architecture and features

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 28, 2017 4:53 AM
    Moderator
  • It will be great if you can share which outlook version does support inserting the HTML code(Java script code) above as HTMLBody of mail item.

    This information help me, does office 365 outlook supports?

    Tuesday, March 28, 2017 5:24 AM
  • Hello Aresha,

    Outlook doesn't support running script in body.

    Regards,

    Celeste


    MSDN Community Support
    Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, March 28, 2017 8:33 AM
    Moderator