Is there any technique using which we can send Email to anyone in Javascript...? If there is, pls. tell me...!! Thanx in Advance...
Is there any technique using which we can send Email to anyone in Javascript...? If there is, pls. tell me...!! Thanx in Advance...
I dont think there is anyway to send mail using javascript as it it client side scripting.
You need to use client side scripting.
this is the code that you require to send mail
<script language="JavaScript" src="sendemail.js"></script>
line in your web page.
//First create the Mail() object and set in on a variable
var easymail=new Mail();
//Set the server type, so the script can know which page to call, the asp or php, if you are using a PHP server
//replace the "ASP_SERVER" wit // h "PHP_SERVER", by default the // server is set to PHP_SERVER
//NOTE: If you choose ASP_SERVER you must have CDONTS component installed
//in your server in order to send the em // ails
easymail.ServerType=ASP_SERVER;
//Now set the address to which the email will be sended
easymail.To="username@email.com";
//Add the CC address
easymail.Cc="username2@email.com";
//Add the BCC address
easymail.Bcc="username3@email.com";
//Now set the address of the one that sends the email
easymail.ReplyTo="me@email.com";
//Now set the subject of the email
easymail.Subject="Here goes the subject of the email";
//Set the message of the email
easymail.Message="Here is the content of the email message, if you want to split text into lines so it can be readable, you can use the '\r\n' characters, or better";
//Send the email
easymail.Send();
Now, if you want to know if the ASP/PHP was already loaded and/or if you want to know if the email was sended correctly, you can use some special variables which are:
1. EmailSenderAccessed - If it is set to true then the ASP/PHP email page was loaded
2. EmailSended - If it is set to true then the email was sended correctly
I have included some code so you can know if the email page was loaded and if the email was sended correctly, add the following code to the previous one.
function CheckEmail(){
//Show the message in the status bar
// window.status="Sending email...";
//Check if the ASP/PHP email page was al // ready loaded
if(EmailSenderAccessed){
//Now check if the email was sended or n // ot and show the message
if(EmailSended) window.alert("The email was sended succesully!");
else window.alert("The email could not be sended");
}
//If ASP/PHP email page is not loaded ye // t, then check it again in 0.5 seconds (500 milliseconds)
else{
setTimeout("CheckEmail();", 500);
}
}
//Send the email
easymail.Send();
//Now call the function what will alert // user when email was sended
CheckEmail();
Bookmarks