Link to home
Start Free TrialLog in
Avatar of raj3060
raj3060Flag for United States of America

asked on

Send Page by E-Mail command

Hi Experts,
Do we have any equivalent command for Send Page by E-Mail like there is for Save, SaveAs, Copy, and so on like this:
document.execCommand('SaveAs');

I tried this but did not work:
document.execCommand('SendPagebyE-Mail');

Any suggestions..
SOLUTION
Avatar of sajuks
sajuks

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raj3060

ASKER

When we click on Send Page by Email from file menu in internet explorer or Word, it does open your email client with the page attached. I was wondoring if we can have a button inside the page to call that command, like we can for SaveAs, Print etc. It is also windows command, shouldn't we have something equivalent to other commands.
-Raj
Avatar of sajuks
sajuks

Its using the mailto: command.Not a recommended method.Check the below ex
<html>
<head>
<title>TEST</title>
<script type="text/javascript">
<!--
function mailIt(fObj){
    fObj.encoding = 'text/plain';
    fObj.action = "mailto:abc@ced.com?subject=URL"
}
window.onload = function(){
     document.forms[0].Please_See_This_Link.value = window.location;
}
// -->
</script>
</head>
<body>
<form name="form1" method="post" action="" onsubmit="mailIt(this);">
<input type="text" name="Please_See_This_Link">
<input type="submit" name="Submit" value="Submit">
</form>
</body>
</html>
Avatar of raj3060

ASKER

That is not what I am looking, try to open some word document or any web page and then from file menu select Send and then click on Page by E-Mail, and see what it does, it will open you email client with that page attached.
I am looking for the document.execCommand('SendpagebyE-Mail') equivalent.
-Raj
Sorry but that functionality is not available
Avatar of raj3060

ASKER

grrrrrrrrrrrrrrr.. Let's wait and see if any one else knows anything abt it..
you can use ASP like so:

<%
Set myMail=CreateObject("CDO.Message")
myMail.Subject="Sending email with CDO"
myMail.From="mymail@mydomain.com"
myMail.To="someone@somedomain.com"
myMail.CreateMHTMLBody "https://www.experts-exchange.com
myMail.Send
%>

you can only send HTML files not ASP or PHP or ect.
OR this one

<HTML>
<HEAD>
<script language="Javascript">

function setHTML(){
      document.frm1.htmlbody.value=document.body.parentNode.outerHTML;
}
          
</script>
</HEAD>
<BODY onload="setHTML()">

<form name="frm1" action="email.asp" method="post">
Email:<input type="text" name="Email">
<input type="submit" name="submit" value="Submit">
<input type="hidden" name="htmlbody">
</form>

<%

   if Request.Form("email")<>"" Then
      Set myMail=Server.CreateObject("CDO.Message")
      myMail.Subject="Message Subject"
      myMail.From="mymail@mydomain.com"
      myMail.To=Request.Form("email")
      myMail.HTMLBody = Request.Form("htmlbody")
      myMail.Send
    End If
%>
</BODY>
</HTML>
save both pages as "email.asp"

<HTML>
<HEAD>
<script language="Javascript">

function setHTML(){
    document.getElementById("an").href="mailto:"+document.frm1.email.value+"?body="+document.body.parentNode.outerHTML;
}
         
</script>
</HEAD>
<BODY>
<form name="frm1">
Email:<input name="email" onchange="setHTML()"><a href="#">Send Email</a>
</form>


</BODY>
</HTML>
sorry not that one...


<HTML>
<HEAD>
<script language="Javascript">

function setHTML(){
    document.getElementById("an").href="mailto:"+document.frm1.email.value+"?body="+document.body.parentNode.outerHTML;
}
         
</script>
</HEAD>
<BODY>
<form name="frm1">
Email:<input type="text" name="email"><a id="an" href="#" onmouseover="setHTML()">Send Email</a>
</form>


</BODY>
</HTML>


either one is the most stupid way of doing this  :)
Avatar of raj3060

ASKER

Using JSP/JAVA..
My requirement is that I have a JSP page that has data coming From DB. Now allow user to either print this page or email the page as attachement.
Any suggestion?
Avatar of raj3060

ASKER

Increasing the points to 500
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raj3060

ASKER

That is the email program, does not tell anything how to attach a page to email.
Hi,

I know it's not what you asked for..but could you either:

a) frame the page in the email body (resident on server, dynamic content from db)

or

b) include a link to the page online?

The user could do everything they could if the file was an attachment...

Avatar of raj3060

ASKER

dreamer007, that's a good idea. Please give me example how to do it.
Thanks
Ok,

Quick and dirty way:

<a href="mailto:11811@eircom.net?Body=Please view your file:%0A%0Ahttp://www.thisisyourname.com/demo/file.txt%0A%0APrint it:%0A%0Ahttp://www.thisisyourname.com/demo/file.html">Send Link to a File</a></p>

The first link in the email is a standard txt file, so it opens - the user can print if they want.

The second one is a html file, with <body onload="window.print()"> in it, so it requests a print operation as soon as it's finished.

You could use an SSI to include another document, if it's not possible to have the onload inserted automatically.

The not-so-quick-and-much-cleaner is a custom (PHP for example) scrpt that sends HTML to frame the file.

d.
Avatar of raj3060

ASKER

Points refund. Didn't get what I was looking for.
Thanks
> Didn't get what I was looking for.

you ain't getting it yet, because it's impossible and you have to accept the truth, what so many experts put so much effort in it and you are going to delete this question just like that? you were presented with various ways of doing what you asked for and use them...
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of raj3060

ASKER

I will give points tomorrow.
Thanks all.
Avatar of raj3060

ASKER

>>you were presented with various ways of doing what you asked for and use them...

What if it don't work for me? None of these solutions work for me. Before I asked this question I tried everything (as far as I know).
Anyway points are granted. Thanks for all your efforts and sharing the knowledge.
you wanted "document.execCommand('SendpagebyE-Mail')" which doesn't exists, we showed you what exists and what you can use to achieve this, and you have to put up with this wether you like it or not...   :)