CDONTS to CDO script with saved fields

S

Shona

I've managed to change the basic cdo script
(http://www.aspfaq.com/show.asp?id=2026)



and it all works fine but in my cdont's script I had some extra lines.
These lines work fine in cdon'ts






I now get an error message in my cdo script
Microsoft VBScript runtime error '800a01a8'

Object required: ''

Confirmation3.asp, line 88



This is the Cdon'ts script which does exactly what I want it to do

<%
Set objCDOMail = Server.CreateObject("CDONTS.NewMail")
objCDOMail.To = "mymail@com"
objCDOMail.From = FP_SavedFields("Name") & "." & FP_SavedFields("Surname") &
"@com "& " <" & FP_SavedFields("Name") & "." & FP_SavedFields("Surname") &
"@com" & ">"
objCDOMail.Subject = FP_SavedFields("Results")

strBody = strBody & "Dear " & FP_SavedFields("Name") & VbCrLf



strBody = strBody & "" & FP_SavedFields("Comment") & VbCrLf
objCDOMail.Body = strBody
objCDOMail.BodyFormat = 1
objCDOMail.MailFormat = 1
objCDOMail.Send
Set objCDOMail = Nothing
%>


This is the CDO script I've tried that gives me the error message also the
mail is not received



<%
Set cdoConfig = CreateObject("CDO.Configuration")

With cdoConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "myserver"
.Update
End With

Set cdoMessage = CreateObject("CDO.Message")

With cdoMessage
Set .Configuration = cdoConfig
.From = "mymail@com"
.To = "mymail@com"



.Subject = "Sample CDO Message"
objCDOMail.From = FP_SavedFields("Name") & "." & FP_SavedFields("Surname")
& "@com "& " <" & FP_SavedFields("Name") & "." & FP_SavedFields("Surname")
& "@com" & ">"
objCDOMail.Subject = FP_SavedFields("Results")

strBody = strBody & "Dear " & FP_SavedFields("Name") & VbCrLf



strBody = strBody & "" & FP_SavedFields("Comment") & VbCrLf
objCDOMail.Body = strBody
.Send
End With

Set cdoMessage = Nothing
Set cdoConfig = Nothing
%>


Can anyone tell me where I'm going wrong?

Many thanks Shona
 
J

Jon

Hi Shona,
you need to include the cdo type library - copy and paste this above your
script
<!--
METADATA
TYPE="typelib"
UUID="CD000000-8B95-11D1-82DB-00C04FB1625D"
NAME="CDO for Windows 2000 Library"
-->
<%
' your script
%>

(it needs to be outside your asp tags) and you should be in business

Jon
Microsoft MVP - FP
 
S

Shona

Hi Jon

thanks for the reply but I already have that included.

Any other ideas?

Cheers Shona
 
J

Jon

Hi,
thought that was too easy :) I think the error is here
objCDOMail.From = FP_SavedFields("Name") & "." & FP_SavedFields("Surname")
& "@com "& " <" & FP_SavedFields("Name") & "." & FP_SavedFields("Surname")
& "@com" & ">"
objCDOMail.Subject = FP_SavedFields("Results")

Your message object is cdoMessage but in this part you're referencing
objCDOMail (I'm guessing you copied this from your old cdonts script) It
should be something like this
With cdoMessage
Set .Configuration = cdoConfig
.From = FP_SavedFields("Name") ' etc.....
.To = "mymail@com"
.Subject = FP_SavedFields("Results")
.TextBody = strBody
.Send
end with

Jon
Microsoft MVP - FP
 
S

Shona

Thanks so nearly there!

..TextBody = strBody & "Dear " & FP_SavedFields("Name") & VbCrLf


..TextBody = strBody & "" & FP_SavedFields("Comment") & VbCrLf

but it only puts the last one comment in the mail.

Tried addying another field after Comment and then it just added that one
and not comment. How do I make it pick up all of the saved fields?

Cheers Shona
 
J

Jon

strBody = "Dear " & FP_SavedFields("Name") & VbCrLf
strBody = strBody & FP_SavedFields("Comment") & VbCrLf
and then
..TextBody = strBody

Jon
 
S

Shona

Any chance you know where I can find the script to put a button on the page
which prints the page do you?

Thanks again Shona
 
J

Jon

Hi,
<form>
<input type="button" onclick="if(window.print)window.print();" value="Print
It">
</form>

Jon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Is this CDO as opposed to CDONT 3
database and e-mail 1
CDO 0
Cdont's script 2
Form results via email in exchange environment 0
CDO help 2
Mass mailing using cdonts 2
cdo nearly there I think 3

Top