Copy To Clipboard HTML EMAIL

Posted on 2007-07-24
Last Modified: 2013-11-26
I am working in sending out email through the system.web.mail control
I would like to add a button to this email that will allow the recipient to copy the contents of the email to their clipboard.
I can assign the contents to the button on my side before it is sent / or the code can select the contents of the email on the user side and add it to their clip board.  Either solution would work.

I have not been able to find any code html code that will copy a string to the user's clipboard.

Thank you for the help
Question by:Devlinmc
    LVL 54

    Expert Comment

    HTML alone can't do it.  There are some options using clientside script though (i.e. Javascript or vbscript).  Will this just need to be for IE or does it need to work in all browsers?  Does the "html code" actually have html tags, etc or is it just text?

    If you want it cross browser then you will have to use Javascript.  Let me know about the stuff above and I can offer some code.  Keep in mind this type of script can have questionable support in browsers simply because of the browser security involved.  For example if scripts are disabled it won't work at all.


    Author Comment

    Thanks for the quick responce.
    It does not need to cross browsers, ie is fine.
    and no, the current email is only text, and is actually going in text format.  But this i know how to change.
    LVL 54

    Accepted Solution

    Thanks for making it easy. :)

    <script type="text/javascript">

    function ClipBoard()
    if (document.all) {
        var str = "The text you want to copy";
        holdtext.innerText = str
        Copied = holdtext.createTextRange();
    } else return false;


    Let me know how that works.  It is the simplest way to do it but should work in IE.  It will only work in IE though. :)

    LVL 54

    Expert Comment

    That script was adapted from script I got at


    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
    This is a PowerShell web interface I use to manage some task as a network administrator. Clicking an action button on the left frame will display a form in the middle frame to input some data in textboxes, process this data in PowerShell and display…
    In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
    The viewer will learn the benefit of using external CSS files and the relationship between class and ID selectors. Create your external css file by saving it as style.css then set up your style tags: (CODE) Reference the nav tag and set your prop…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    9 Experts available now in Live!

    Get 1:1 Help Now