473,385 Members | 1,615 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with JavaScript CDONTS code

I have the following code in an ASP webpage where a member has logged
in and wants to change his company information. This page lists the
fields and records currently in our database (Access) and he is able to
make changes and submit it. My code updates the database fine and
redirects them to another page fine.

Now I want that information emailed to me as well. I have found code
and spent hours tweeking it to work and I finally get NO errors. The
only problem is that when I receive the e-mail, all of the fields say
undefined instead of the actual record. For instance:

THIS IS THE EMAIL:

Company: undefined
Division: undefined
Mailing Address: undefined

THIS IS THE CODE:

<%

var objCDO = Server.CreateObject("CDONTS.NewMail");
objCDO.From = "webmaster@...org"
objCDO.To = "me@...org"
objCDO.Subject = "Member Company Updated!"
objCDO.Body = "The following member company information has been
updated." + "\n\n"
+ "Company: " + Request.Form("MbrCompany") + "\n"
+ "Division: " + Request.Form("email") + "\n"
+ "Mailing Address: " + Request.Form("MbrMailingAddress") + "\n"
+ "Mailing City, State, Zip: " + Request.Form("MbrMailingCity") + " "
+ Request.Form("MbrMailingState") + " " + Request.Form("MbrMailingZip")
+ "\n\n"
+ "Shipping Address: " + Request.Form("MbrShippingAddress") + "\n"
+ "Shipping City, State, Zip: " + Request.Form("MbrShippingCity") + "
" + Request.Form("MbrShippingState") + " " +
Request.Form("MbrShippingZip") + "\n\n"
+ "Phone: " + Request.Form("MbrMainPhone") + "\n"
+ "Alt Phone: " + Request.Form("MbrAltPhone") + "\n"
+ "Fax: " + Request.Form("MbrMbrFax") + "\n"
+ "Intl Phone: " + Request.Form("MbrPhoneIntl") + "\n"
+ "Intl Fax: " + Request.Form("MbrFaxIntl") + "\n"
+ "Email: " + Request.Form("MbrEmail") + "\n"
+ "Website: " + Request.Form("MbrWebsite") + "\n\n"
+ "Please file this in the member's folder."
objCDO.BodyFormat = 1
objCDO.MailFormat = 1
objCDO.Send()
objCDO = null

%>

Any help????

Jul 23 '05 #1
4 2700


cm*******@nfda-fastener.org wrote:
I have the following code in an ASP webpage where a member has logged
in and wants to change his company information. This page lists the
fields and records currently in our database (Access) and he is able to
make changes and submit it. My code updates the database fine and
redirects them to another page fine.

Now I want that information emailed to me as well. I have found code
and spent hours tweeking it to work and I finally get NO errors. The
only problem is that when I receive the e-mail, all of the fields say
undefined instead of the actual record. For instance:

THIS IS THE EMAIL:

Company: undefined objCDO.Body = "The following member company information has been
updated." + "\n\n"
+ "Company: " + Request.Form("MbrCompany") + "\n"


Well if it says undefined then in the ASP page with that code
Request.Form("MbrCompany") yields undefined. As you say that you
redirect then the problem is probably simply that HTTP POST information
is not transferred when redirecting thus any attempt in ASP to read
Request.Form("argname") will give you undefined.
Or that ASP page receives the data in the query string part of the URL
and then
Request.QueryString("MbrCompany")
is the proper way to extract the data.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #2
Thanks for the response Martin. I tried replacing the Request.Form with
Request.QueryString, but it still gives me undefined values in the
email. Any other suggestions?

Jul 23 '05 #3


ConnieM wrote:
I tried replacing the Request.Form with
Request.QueryString, but it still gives me undefined values in the
email. Any other suggestions?


For a start don't bother with emailing stuff but find out first how data
is passed to the page, if no data is passed to the page in the query
string then Request.QueryString can't give you any data in the ASP page.
All you are doing is building a string e.g.

"The following member company information has been
updated." + "\n\n"
+ "Company: " + Request.Form("MbrCompany") + "\n"
+ "Division: " + Request.Form("email") + "\n"

or now

"The following member company information has been
updated." + "\n\n"
+ "Company: " + Request.QueryString("MbrCompany") + "\n"
+ "Division: " + Request.QueryString("email") + "\n"

obviously in ASP those Request properties do only reflect what is passed
to the page thus if you get undefined then nothing has been passed to
the page.

So you need to look at how data is passed to the page, to have data in
the query string you for instance would need a link alike
<a href="http://example.com/mail.asp?MbrCompany=company&email=whoever">
the ASP will have values for
Request.QueryString("MbrCompany")
and
Request.QueryString("email")

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 23 '05 #4
"ConnieM" <cm*******@nfda-fastener.org> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Thanks for the response Martin. I tried replacing the Request.Form
with
Request.QueryString, but it still gives me undefined values in the
email. Any other suggestions?


As Martin has already suggested, you mention that you "redirect to
another page" after processing the form. This will result in "throwing
away" all the values of the Request.QueryString() and Request.Form()
collections.

A redirect simply tells the browser to do a GET on the new URL, anything
in the POST buffer (or originally passed to <FORM
ACTION="yourFormHandler.asp?Something=Whatever">) is lost when the
browser requests the new page.

If you actually want to pass data from the page that handles <FORM
ACTION="..."> to a new page, you have two options:

1) store the values of the form in the Session object and retrieve them
on the new page (I don't recommend this)
2) take the values obtained from Request.Form(), write script to build a
query string containing the information you want and pass it to the
redirect page as part of the redirect.

So, on the page that handles <FORM ACTION="...">

<%
var CompanyNameVar = Request.Form('CompanyName');
var BlahBlahVar = Request.Form('BlahBlah');
var SomethingElseVar = Request.Form('SomethingElse');

// update the database and do whatever

Response.Redirect(
"SendEmail.asp?" +
"CompanyName=" +
Server.URLencode(CompanyNameVar) +
"&BlahBlah=" +
Server.URLencode(BlahBlahVar));
%>

NOW the values of CompanyName, BlahBlah (but NOT SomethingElse) will be
accessible to SendEmail.asp using Request.QueryString(). If you want
SomethingElse too, _you_ have to include it on the query string passed
to SendEmail.asp.

Of course, if you try to pass large (> 512 bytes) of information this
way, you run the risk that the browser won't pass the entire query
string correctly, resulting in lost data.

--
Grant Wagner <gw*****@agricoreunited.com>
comp.lang.javascript FAQ - http://jibbering.com/faq
Jul 23 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: | last post by:
Hi Guys CDONTS works with all sites hosted on my test server bar one (which surely rules out a miscomputation of the Default SMTP server in IIS). I have tried uploading the file with make up...
29
by: | last post by:
I did a working code with CDONTS on NT4 Now I am testing is on w2k and it looks like objCDONTS.Send is completely ignored. I think is it ignored because it throws no errors, neither does the...
44
by: Mike | last post by:
I'm used to unix/cgi scripts so im slightly out of my depth here. Ive got an asp script for a website form which works fine. What i want to do is also get the form to include the ip address of the...
2
by: Savas Ates | last post by:
im sending email with cdonts.. my mail format is html format.. and also in my mail code there are html and javascript codes. i open my mail with outlook it works.. but im sending it to hotmail...
16
by: tshad | last post by:
I have both cdosys.dll and cdonts.dll on my W2K3 server. We have been told by our web authors that their asp code won't work on our machine and that we don't have CDONTS installed on our machine....
9
by: scott | last post by:
I have my win 2003 server setup correct with SMTP. I know because I've tested it ok. However, when I issue CODE 1 below, I get ERROR 1 below. I thought having SMTP installed correctly allowed...
2
by: Joey | last post by:
I am currently developing a C# asp.net application where users are required to register. The application then generates a simple, plain text email and sends it to the new user. I have been...
14
by: tbird2340 | last post by:
I want to write an if / then statement and have tried using this: var MyVarMailto; if (Request.Form("LoanRequest") == "Under $250,000") { if (Request.Form("Organization") == "1") { MyVarMailto...
7
by: Paul | last post by:
I have just started work on a system using CDONTS to mail out. Whilst this is fine on the server, my local development machine is using XP Pro with IIS5.1 installed. Is there a way I can get the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.