PDA

Click to See Complete Forum and Search --> : how do i use javascript to e-mail something


royjacob
Aug 13th, 2000, 01:06 PM
ok i'm relatively new to javascript, but i'm pretty good. one thing i've been trying to do with javascript is to send an e-mail message using javascript's Sendmail() object. However, nothing ever happens when i use it. if anyone knows how to do this, please help me.

RealisticGraphics
Aug 18th, 2000, 09:45 PM
First off, This is core javascript. It is only supported server side and to the best of my knowledge is only supported in a Netscape's Server-Side Addition. Here is a simple example of what the code looks like:


<server>
//See what's happening
if(request.method == "POST"){

//create a new mail object
var tMail = new SendMail();

//assign some values
tMail.To = request.To;
tMail.From = request.From;
tMail.Subject = request.Subject;
tMail.Body = request.Message;
tMail.Smtpserver = "mail.yourserver.com";

//Try to send
if(!myMail.send()){
alert(tMail.errorCode() + ": " + tMail.errorMessage());
}
else{
alert("Mail Sent.");
}
}
</server>
<form name="MailForm" Method=POST>
To: <input type="text" name="To"><br>
From: <input type="text" name="From"><br>
Subject: <input type="text" name="Subject"><br>
Message: <TextArea name="Message" cols=50 rows=15><br>
<input type="submit" value="Send"><input type="reset" value="Clear">
</form>


Hope this helps.