Copy filepath to clipboard & paste it in outlook. How?

T

tabonni

Hello All

I am creating an ASP page. There are a list of filename and checkbox
next to it. When user checked all the documents they want and click
ADD TO CLIPBOARD button. All filepaths will be copied into clipboard
and then they can right-click -> paste into MS Outlook as attachments.

How can I use clipboardData.setData function to do that? I saw a lot
of examples they are just copy and paste text.

Thanks
 
M

McKirahan

tabonni said:
Hello All

I am creating an ASP page. There are a list of filename and checkbox
next to it. When user checked all the documents they want and click
ADD TO CLIPBOARD button. All filepaths will be copied into clipboard
and then they can right-click -> paste into MS Outlook as attachments.

How can I use clipboardData.setData function to do that? I saw a lot
of examples they are just copy and paste text.

Thanks

Will this help? Watch for word-wrap.

<html>
<head>
<title>Clipper.htm</title>
<script type="text/javascript">
function checks() {
var form = document.form1;
var what = "";
for (var i=0; i<form.files.length; i++) {
if (form.files.checked) {
what += form.files.value + "\n";
}
}
alert("Clipboard = \n\n" + what);
window.clipboardData.setData("Text", what)
}
</script>
</head>
<body>
<form name="form1">
<br><input type="checkbox" name="files" value="c:\temp\file1.txt"> file1
<br><input type="checkbox" name="files" value="c:\temp\file2.txt"> file2
<br><input type="checkbox" name="files" value="c:\temp\file3.txt"> file3
<br><input type="button" value="Clipboard" onclick="checks()">
</form>
</body>
</html>
 
T

tabonni

But, when I paste it into outlook. It is not a real file, just text
c:/Temp/file1.txt.

How can I copy the file and paste the real document in outlook? It is
like insert attachments in outlook?

cheers

McKirahan said:
tabonni said:
Hello All

I am creating an ASP page. There are a list of filename and checkbox
next to it. When user checked all the documents they want and click
ADD TO CLIPBOARD button. All filepaths will be copied into clipboard
and then they can right-click -> paste into MS Outlook as attachments.

How can I use clipboardData.setData function to do that? I saw a lot
of examples they are just copy and paste text.

Thanks

Will this help? Watch for word-wrap.

<html>
<head>
<title>Clipper.htm</title>
<script type="text/javascript">
function checks() {
var form = document.form1;
var what = "";
for (var i=0; i<form.files.length; i++) {
if (form.files.checked) {
what += form.files.value + "\n";
}
}
alert("Clipboard = \n\n" + what);
window.clipboardData.setData("Text", what)
}
</script>
</head>
<body>
<form name="form1">
<br><input type="checkbox" name="files" value="c:\temp\file1.txt"> file1
<br><input type="checkbox" name="files" value="c:\temp\file2.txt"> file2
<br><input type="checkbox" name="files" value="c:\temp\file3.txt"> file3
<br><input type="button" value="Clipboard" onclick="checks()">
</form>
</body>
</html>
 
M

McKirahan

tabonni said:
But, when I paste it into outlook. It is not a real file, just text
c:/Temp/file1.txt.

How can I copy the file and paste the real document in outlook? It is
like insert attachments in outlook?

cheers

[snip]

You originally asked that "All filepaths will be copied into clipboard";
"c:/Temp/file1.txt" is a filepath.

To copy all files checked into the clipboard, try:

<html>
<head>
<title>file0.htm</title>
<script type="text/javascript">
function checks() {
var form = document.form1;
var j = 0;
var list = new Array;
var what = "";
//
for (var i=0; i<form.files.length; i++) {
if (form.files.checked) {
list[j++] = form.files.value;
what += "\n" + form.files.value;
}
}
alert("Clipboard List =\n" + what);
window.clipboardData.setData("Text", what)
what = "";
//
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
for (var k=0; k<list.length; k++) {
var oOTF = oFSO.OpenTextFile(list[k],1);
var sOTF = oOTF.ReadAll();
what += "\n" + sOTF;
}
alert("Clipboard Data =\n" + what);
window.clipboardData.setData("Text", what)
}
</script>
</head>
<body>
<form name="form1">
<br><input type="checkbox" name="files" value="c:\temp\file1.txt"> file1
<br><input type="checkbox" name="files" value="c:\temp\file2.txt"> file2
<br><input type="checkbox" name="files" value="c:\temp\file3.txt"> file3
<br><input type="button" value="Clipboard" onclick="checks()">
</form>
</body>
</html>

Be aware that you will get a security warning as FSO is an ActiveX control.

Also, there is a limit to how much data can be placed into the clipboard.
 
T

tabonni

It doesn't work. After I checked the files and clicked the Clipboard
button, I tried to paste it in MS outlook. However, files cannot be
pasted. And, the outlook message and the html page (containing
checkboxes and button one) are not responding.

By the way, how can I copy and paste PDF Files?

I should clarify everything in the beginning. Sorry.

Cheers
McKirahan said:
tabonni said:
But, when I paste it into outlook. It is not a real file, just text
c:/Temp/file1.txt.

How can I copy the file and paste the real document in outlook? It is
like insert attachments in outlook?

cheers

[snip]

You originally asked that "All filepaths will be copied into clipboard";
"c:/Temp/file1.txt" is a filepath.

To copy all files checked into the clipboard, try:

<html>
<head>
<title>file0.htm</title>
<script type="text/javascript">
function checks() {
var form = document.form1;
var j = 0;
var list = new Array;
var what = "";
//
for (var i=0; i<form.files.length; i++) {
if (form.files.checked) {
list[j++] = form.files.value;
what += "\n" + form.files.value;
}
}
alert("Clipboard List =\n" + what);
window.clipboardData.setData("Text", what)
what = "";
//
var oFSO = new ActiveXObject("Scripting.FileSystemObject");
for (var k=0; k<list.length; k++) {
var oOTF = oFSO.OpenTextFile(list[k],1);
var sOTF = oOTF.ReadAll();
what += "\n" + sOTF;
}
alert("Clipboard Data =\n" + what);
window.clipboardData.setData("Text", what)
}
</script>
</head>
<body>
<form name="form1">
<br><input type="checkbox" name="files" value="c:\temp\file1.txt"> file1
<br><input type="checkbox" name="files" value="c:\temp\file2.txt"> file2
<br><input type="checkbox" name="files" value="c:\temp\file3.txt"> file3
<br><input type="button" value="Clipboard" onclick="checks()">
</form>
</body>
</html>

Be aware that you will get a security warning as FSO is an ActiveX control.

Also, there is a limit to how much data can be placed into the clipboard.
 
M

McKirahan

tabonni said:
It doesn't work. After I checked the files and clicked the Clipboard
button, I tried to paste it in MS outlook. However, files cannot be
pasted. And, the outlook message and the html page (containing
checkboxes and button one) are not responding.

It works if they're ".txt" files.
By the way, how can I copy and paste PDF Files?

You can't.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,043
Latest member
CannalabsCBDReview

Latest Threads

Top