Thread View: comp.lang.javascript
5 messages
5 total messages
Started by Ben
Wed, 24 Jul 2002 17:20
Sending a CDONTS email
Author: Ben
Date: Wed, 24 Jul 2002 17:20
Date: Wed, 24 Jul 2002 17:20
57 lines
2735 bytes
2735 bytes
Hi Guys,
Can anyone help! I am trying to put together a basic cookie in JavaScript.
The cookie part of the script it working perfectly, no problems there.
However after the cookie has been executed I want the script to send an
email using CDONTS. This is where I am having problems.
I only want the email to be sent if the cookie is executed ie if it exists.
Currently nothing is working, if I take out the email side of the script the
cookie works, but I need both running.
Any ideas where I am going wrong?
<script>
<!--
// page to go to if cookie exists
go_to = "software.htm";
// number of days cookie lives for
num_days = 1;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = document.cookie.indexOf(cookieName);
if (start == -1){
document.cookie = "seenit=yes; expires=" + ged(num_days);
} else {
window.location = go_to;
}
}
readCookie("seenit");
// now send the email using CDONTS
Set sendmail = Server.CreateObject("CDONTS.NewMail")
sendmailMsg.From = email@email.com
sendmailMsg.To = user@user.com
sendmailMsg.subject = "Subject"
sendmailMsg.body = "Body"
sendmailMsg.send
// -->
</script>
Hope you can help!
Cheers
Ben
Re: Sending a CDONTS email
Author: Ben
Date: Wed, 24 Jul 2002 17:58
Date: Wed, 24 Jul 2002 17:58
71 lines
3109 bytes
3109 bytes
Sorry it doesn't have to be CDONTS, I just need the cookie to send an
email!!
--
I'm a socialist saving up to become a capitalist.
http://fly.to/bendyer
"Ben" <ben@iow-office.fsnet.co.uk> wrote in message
news:ahmnhu$cg$1@news5.svr.pol.co.uk...
> Hi Guys,
>
> Can anyone help! I am trying to put together a basic cookie in JavaScript.
> The cookie part of the script it working perfectly, no problems there.
> However after the cookie has been executed I want the script to send an
> email using CDONTS. This is where I am having problems.
>
> I only want the email to be sent if the cookie is executed ie if it
exists.
> Currently nothing is working, if I take out the email side of the script
the
> cookie works, but I need both running.
>
> Any ideas where I am going wrong?
>
> <script>
> <!--
>
>
> // page to go to if cookie exists
> go_to = "software.htm";
>
> // number of days cookie lives for
> num_days = 1;
> function ged(noDays){
> var today = new Date();
> var expr = new Date(today.getTime() + noDays*24*60*60*1000);
> return expr.toGMTString();
> }
>
> function readCookie(cookieName){
> var start = document.cookie.indexOf(cookieName);
> if (start == -1){
> document.cookie = "seenit=yes; expires=" + ged(num_days);
> } else {
> window.location = go_to;
> }
> }
>
> readCookie("seenit");
>
> // now send the email using CDONTS
>
> Set sendmail = Server.CreateObject("CDONTS.NewMail")
> sendmailMsg.From = email@email.com
> sendmailMsg.To = user@user.com
> sendmailMsg.subject = "Subject"
> sendmailMsg.body = "Body"
> sendmailMsg.send
>
> // -->
> </script>
>
>
> Hope you can help!
>
> Cheers
>
> Ben
>
>
Re: Sending a CDONTS email
Author: Grant Wagner
Date: Wed, 24 Jul 2002 18:32
Date: Wed, 24 Jul 2002 18:32
89 lines
3792 bytes
3792 bytes
Client-side JavaScript has no ability to send an E-mail.
It can attempt to navigate to a "mailto:" URL, but that won't be automated and
will require user intervention to send (assuming it works at all, some users
don't have an E-mail client configured to come up for "mailto:" URLs).
Read the cookie from the server, send the E-mail from there.
Ben wrote:
> Sorry it doesn't have to be CDONTS, I just need the cookie to send an
> email!!
>
> --
> I'm a socialist saving up to become a capitalist.
>
> http://fly.to/bendyer
>
> "Ben" <ben@iow-office.fsnet.co.uk> wrote in message
> news:ahmnhu$cg$1@news5.svr.pol.co.uk...
> > Hi Guys,
> >
> > Can anyone help! I am trying to put together a basic cookie in JavaScript.
> > The cookie part of the script it working perfectly, no problems there.
> > However after the cookie has been executed I want the script to send an
> > email using CDONTS. This is where I am having problems.
> >
> > I only want the email to be sent if the cookie is executed ie if it
> exists.
> > Currently nothing is working, if I take out the email side of the script
> the
> > cookie works, but I need both running.
> >
> > Any ideas where I am going wrong?
> >
> > <script>
> > <!--
> >
> >
> > // page to go to if cookie exists
> > go_to = "software.htm";
> >
> > // number of days cookie lives for
> > num_days = 1;
> > function ged(noDays){
> > var today = new Date();
> > var expr = new Date(today.getTime() + noDays*24*60*60*1000);
> > return expr.toGMTString();
> > }
> >
> > function readCookie(cookieName){
> > var start = document.cookie.indexOf(cookieName);
> > if (start == -1){
> > document.cookie = "seenit=yes; expires=" + ged(num_days);
> > } else {
> > window.location = go_to;
> > }
> > }
> >
> > readCookie("seenit");
> >
> > // now send the email using CDONTS
> >
> > Set sendmail = Server.CreateObject("CDONTS.NewMail")
> > sendmailMsg.From = email@email.com
> > sendmailMsg.To = user@user.com
> > sendmailMsg.subject = "Subject"
> > sendmailMsg.body = "Body"
> > sendmailMsg.send
> >
> > // -->
> > </script>
> >
> >
> > Hope you can help!
> >
> > Cheers
> >
> > Ben
--
| Grant Wagner <gwagner@agricoreunited.com>
* Client-side Javascript and Netscape DOM Reference available at:
* http://developer.netscape.com/docs/manuals/javascript.html
* Internet Explorer DOM Reference available at:
* http://msdn.microsoft.com/workshop/author/dhtml/reference/dhtmlrefs.asp
* Tips for upgrading JavaScript for Netscape 6/Mozilla
* http://www.mozilla.org/docs/web-developer/upgrade_2.html
Re: Sending a CDONTS email
Author: kaeli
Date: Thu, 25 Jul 2002 13:25
Date: Thu, 25 Jul 2002 13:25
72 lines
3087 bytes
3087 bytes
Ben wrote:
> Hi Guys,
>
> Can anyone help! I am trying to put together a basic cookie in JavaScript.
> The cookie part of the script it working perfectly, no problems there.
> However after the cookie has been executed I want the script to send an
> email using CDONTS. This is where I am having problems.
>
> I only want the email to be sent if the cookie is executed ie if it exists.
> Currently nothing is working, if I take out the email side of the script the
> cookie works, but I need both running.
>
> Any ideas where I am going wrong?
>
Yeah, using server side commands like Server.CreateObject with a
client-side script.
If you have CDONTS, you have ASP. Use that. Server-side VBScript or
JScript is much better for mail than a client-side language that
requires someone have an e-mail client installed and associated with
their browser.
Try the following, tested in IIS/Win2K/IE6 successfully (modify the from and to addresses appropriately).
HTH
kaeli
<%@ LANGUAGE="JSCRIPT"%>
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>test </title>
</head>
<body>
<%
//page to go to if cookie exists
go_to = "software.htm";
//number of days cookie lives for
num_days = 1;
function ged(noDays){
var today = new Date();
var expr = new Date(today.getTime() + noDays*24*60*60*1000);
return expr.toGMTString();
}
function readCookie(cookieName){
var start = Request.Cookies(cookieName);
if (start == ""){
Response.Cookies("seenit")="yes; expires=" + ged(num_days);
} else {
Response.Redirect(go_to);
}
}
readCookie("seenit");
// now send the email using CDONTS
var sendmailMsg = Server.CreateObject("CDONTS.NewMail");
sendmailMsg.From = "email@email.com";
sendmailMsg.To = "mail@mail.com";
sendmailMsg.subject = "Subject";
sendmailMsg.body = "Body";
sendmailMsg.send();
%>
</body>
</html>
Re: Sending a CDONTS email
Author: Dr John Stockton
Date: Thu, 25 Jul 2002 19:13
Date: Thu, 25 Jul 2002 19:13
22 lines
2125 bytes
2125 bytes
JRS: In article <3D3FFC49.5060804@NOSPAMatt.net>, seen in
news:comp.lang.javascript, kaeli <infinite.possibilitiesNOSPAM@NOSPAMatt
.net> posted at Thu, 25 Jul 2002 08:25:29 :-
>function ged(noDays){
> var today = new Date();
> var expr = new Date(today.getTime() + noDays*24*60*60*1000);
> return expr.toGMTString();
>}
function ged(noDays){
with (new Date()) { setDate(getDate()+noDays)
return toGMTString() }
}
is shorter and, in terms of civil days, more accurate.
--
� John Stockton, Surrey, UK. jrs@merlyn.demon.co.uk Turnpike v4.00 MIME. �
Web <URL:http://www.merlyn.demon.co.uk/> - w. FAQish topics, links, acronyms
PAS EXE etc : <URL:http://www.merlyn.demon.co.uk/programs/> - see 00index.txt
Dates - miscdate.htm moredate.htm js-dates.htm pas-time.htm critdate.htm etc.
Thread Navigation
This is a paginated view of messages in the thread with full content displayed inline.
Messages are displayed in chronological order, with the original post highlighted in green.
Use pagination controls to navigate through all messages in large threads.
Back to All Threads