Copy To Clipboard HTML EMAIL

I am working in Vb.net 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
DevlinmcAsked:
Who is Participating?
 
b0lsc0ttIT ManagerCommented:
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();
    Copied.execCommand("Copy");
} else return false;
}

</script>

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. :)

bol
0
 
b0lsc0ttIT ManagerCommented:
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.

bol
0
 
DevlinmcAuthor Commented:
Bol,
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.
0
 
b0lsc0ttIT ManagerCommented:
That script was adapted from script I got at http://www.htmlgoodies.com/beyond/javascript/article.php/3458851.

bol
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.