 |
BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4  | This is the forum to discuss the Wrox book Beginning Dreamweaver MX by Charles E. Brown, Imar Spaanjaars, Todd Marks; ISBN: 9780764544040 |
Please indicate which version of the book you are using when posting questions. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the BOOK: Beginning Dreamweaver MX/MX 2004 MX ISBN: 978-0-7645-4404-0; MX 2004 ISBN: 978-0-7645-5524-4 section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

September 24th, 2003, 07:59 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
more chapter 7 forms
greetings
i wonder if you can help me, i have worked through chapter 7 and like some of the other posters on the boards i also want to email the form, (i have a test site that is able to send the email)
I have used the code you posted in the previous topic
http://p2p.wrox.com/topic.asp?TOPIC_ID=1975
and this works fine :)(obviously) to send a basic email
then i thought i would like to expand the contents of the form by adding other textfields eg position, organisation, telephone, fax etc
now the email doesnt work, i get runtime errors saying
Wrong number of arguments or invalid property assignment: 'Form'
Will the .Send method handle information other than From, To, Subject, Body, if it will how do i incorporate it, or do i have to use another method
thanks
steve
|
|

September 24th, 2003, 08:41 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Steve,
You basically send anything you want, as long as you add it to a valid property of the Mail object.
For example, this will work:
Dim Body
Body = Request.Form("txtEmail") & " " & Request.Form("txtFax")
objMsg.Body = Body
This will add both the e-mail address and the fax number to the body of the message.
Can you post some of your code so I can take a look at it?
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 24th, 2003, 08:52 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:) that was quick
<%
Dim objMessage
Set objMessage = Server.CreateObject("CDONTS.NewMail")
objMessage.Send Request.Form("cust_email")," [email protected] k",Request.Form("cust_subject"),Request.Form("cust _name"),Request.Form("cust_position"),Request.Form ("cust_organisation"),Request.Form("cust_address") ,Request.Form("cust_telephone"),Request.Form("cust _fax")
Set objMessage = Nothing
%>
It worked will i had only the From, To, Subject, Body parameters (when the body was just a message
thanks
Steve
|
|

September 24th, 2003, 09:14 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Hi Steve,
Well, it looks like you're mixing up two ways of sending. Either you can set Properties directly on the MailMessage object, or you can pass a few properties directly to the Send method. They can be mixed but it'll only make you code more confusing.
Take a look here:
http://msdn.microsoft.com/library/de...il_object_.asp
You can see that the Send method allows the following params:
Code:
objNewMail.Send( [From] [, To] [, Subject] [, Body] [, Importance] )
Only these 5 items can be passed to the Send method. All other text you need to send, needs to be passed either to the Body property of the MailMessage object (like I showed in my previous post), or passed as the Body parameter for the Send method. Personally, I think the fist method is cleaner:
Code:
Dim Body
Body = "Mail from: " & Request.Form("txtEmail") & " " & Request.Form("txtFax")
Body = Body & "Some Other Text " & vbCrLf
Body = Body & "Some Other Form Field " & Request.Form("SomeField") & vbCrLf
With objMsg
.To = "[email protected]"
.From = "[email protected]"
.Subject = "The subject of the message is " & Request.Form("txtSubject")
.BodyFormat = CdoBodyFormatText ' or CdoBodyFormatHTML
.MailFormat = CdoMailFormatMime ' or CdoMailFormatText
.Body = Body
.Send
End with
Set objMsg = Nothing
As you can see, I build up a body string, based on all kinds of text, both hardcoded and from the Form collection. This Body string is then set as the Body property for the MailMessage object. When you use the Send method, this Body will be send as the text for your e-mail message.
I also added an extra Form field to the Subject property of the message, just to show you that it is possible.
Cheers,
Imar
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 24th, 2003, 09:50 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Ok
here is another attempt :)
<%
Dim Body
Body = Request.Form("cust_name"),("cust_position"),("cust _organisation"),("cust_address"),("cust_telephone" ),("cust_fax"),("cust_email")
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = Request.Form("cust_email")
objNewMail.To = " [email protected]"
objNewMail.Subject = "This is the subject"
objNewMail.BodyFormat = CdoBodyFormatText ' or CdoBodyFormatHTML
objNewMail.MailFormat = CdoMailFormatMime ' or CdoMailFormatText
objNewMail.Body = Body
objNewMail.Send
Set objNewMail = Nothing
%>
Am i any closer?
thanks
Steve :)
|
|

September 24th, 2003, 10:00 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:(
Tried it doesn't work
Microsoft VBScript compilation error '800a0401'
Expected end of statement
/aspTest/onlineFormTestReceive.asp, line 13
Body = Request.Form("cust_name"),("cust_position"),("cust _organisation"),("cust_address"),("cust_telephone" ),("cust_fax"),("cust_email")
--------------------------------^
trying again :)
|
|

September 24th, 2003, 10:09 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
Yeah, Steve, you're closer.
However, you can't create a string (Body) by adding comma separated items. You'll need to concatenate them (don't worry about that too much, Chapter 8 and further will discuss this in great detail) using the & operator:
Dim Body
Body = Request.Form("cust_name") & vbCrLf & ("cust_position") & vbCrLf & ("cust_organisation") & vbCrLf & ("cust_address") & vbCrLf & ("cust_telephone") & vbCrLf & ("cust_fax") & vbCrLf ("cust_email")
This will add the requested items to the Body string, separated by a carriage return and line feed (the constant vbCrlf, discussed in Chapter 9 as well). You can even add some descriptive text:
Dim Body
Body = "Customer name is " & Request.Form("cust_name") & vbCrLf & "Position is " & ("cust_position") & etc etc
HtH
Imar
(Don't try to run the second example as is; etc etc will definitely cause a compile error ;) )
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 24th, 2003, 10:10 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:(
still no luck
<%
Dim Body
Body = Request.Form("cust_name") & " " & Request.Form("cust_position") & " " & Request.Form("cust_organisation") & " " & Request.Form("cust_address") & " " & Request.Form("cust_telephone") & " " & Request.Form("cust_fax") & " " & Request.Form("cust_email")
Dim objNewMail
Set objNewMail = Server.CreateObject("CDONTS.NewMail")
objNewMail.From = Request.Form("cust_email")
objNewMail.To = " [email protected]"
objNewMail.Subject = "This is the subject"
objNewMail.BodyFormat = CdoBodyFormatText ' or CdoBodyFormatHTML
objNewMail.MailFormat = CdoMailFormatMime ' or CdoMailFormatText
objNewMail.Body = Body
objNewMail.Send
Set objNewMail = Nothing
%>
now get this
Body = Request.Form("cust_name"),("cust_position"),("cust _organisation"),("cust_address"),("cust_telephone" ),("cust_fax"),("cust_email") Thank you joe bloggs for your interest, your order is being processed
busily scratching head
steve :)
|
|

September 24th, 2003, 10:27 AM
|
 |
Wrox Author
|
|
Join Date: Jun 2003
Posts: 17,089
Thanks: 80
Thanked 1,576 Times in 1,552 Posts
|
|
What do you mean by "Now get this"? In your e-mail?
That is, does the e-mail get sent correctly?
Is this the entire code for the page that sends the e-mail?
---------------------------------------
Imar Spaanjaars
Everyone is unique, except for me.
|
|

September 24th, 2003, 10:38 AM
|
|
Authorized User
|
|
Join Date: Jun 2003
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
:)
Sorry not being very clear there, that was the error message on trying to send the email
I have now tried two or three different combinations and 1 of them worked :))))))))
just need to figure out which one it was
thanks
steve - will repost my code from the correct one soon :)(i hope)
|
|
 |