Getting a CDONT parameter

S

Simon Wigzell

My website sends automatic emails from many (25) different places. I want to
send a second email by reading the parameters of the first one. I don't want
to have to repeat and maintain the assignment of the second email
From,To,Subject fields so I am just using an include at each point in the
code where I send an email:

Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.BodyFormat= 0
MyCDONTSMail.MailFormat= 1
MyCDONTSMail.From= (e-mail address removed)
MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Subject="some subject"
MyCDONTSMail.Body= "some text":
%>
<!--#include file="SendFollowUpEmail.asp" -->
<%
MyCDONTSMail.Send
set MyCDONTSMail=nothing
-------------------------------------------------------------------------------
The SendFollowUpEmail.asp just wants to take the From,To,Subject parameters
that are defined in the original email and add a different body:

Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
MyCDONTSMail2.BodyFormat= 0
MyCDONTSMail2.MailFormat= 1
MyCDONTSMail2.From= MyCDONTSMail.From
MyCDONTSMail2.To= MyCDONTSMail.To
MyCDONTSMail2.Subject=MyCDONTSMail.Subject
MyCDONTSMail2.Body= "some new text"
MyCDONTSMail2.Send
set MyCDONTSMail2=nothing

It chokes on this:

MyCDONTSMail2.From= MyCDONTSMail.From

Object doesn't support this property or method: 'MyCDONTSMail.From'

Seems to me MyCDONTSMail.From is only a string, why can't I retrieve its
value? More to the point though - how can I retrieve its value?

Thanks!
 
R

Ray Costanzo [MVP]

Instead of doing that, just do:

Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.BodyFormat= 0
MyCDONTSMail.MailFormat= 1
MyCDONTSMail.From= (e-mail address removed)
MyCDONTSMail.Subject="some subject"
MyCDONTSMail.Body= "some text":

MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Send

MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Send

MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Send

MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Send

MyCDONTSMail.To= (e-mail address removed)
MyCDONTSMail.Send

....etc....

Are you running this in a Windows NT server? If not, you shouldn't be using
the old technology CDONTS. Please read:
http://www.aspfaq.com/show.asp?id=2026

Ray at work
 
D

Dave Anderson

Simon said:
It chokes on this:

MyCDONTSMail2.From= MyCDONTSMail.From

Naturally. The [From] property is write-only:
http://msdn.microsoft.com/library/en-us/cdo/html/36d01b22-2cb6-45f9-95d2-e536b8054c57.asp

Use Ray's suggestion. Better yet, use CDO.



--
Dave Anderson

Unsolicited commercial email will be read at a cost of $500 per message. Use
of this email address implies consent to these terms. Please do not contact
me directly or ask me to contact you directly for assistance. If your
question is worth asking, it's worth posting.
 
S

Simon Wigzell

The from address and the to address and the subject aren't known in advance,
I'm talking about a programmed website here.

I just want to know if there is a way to retrieve what has been set into a
CDONT structure, if it isn't possible then say so. I don't want to know a
different way of programming my website, its working fine. So I guess I have
to go back into all 25 pages where I do this and write specific code to send
the second email because it is not possible to retrieve what has been set
into a CDONT, ok, thanks.

(Looking up at the sky and rolling eyes)
 
S

Simon Wigzell

Well - I couldn't have been more explicit describing my problem and what I
wanted to know, yet my problem remains unanswered and unadressed, meanwhile
I have been given some unrelated and useless advice, so yes, you are
probably right.
 
S

Stefan Berglund

in said:
Well - I couldn't have been more explicit describing my problem and what I
wanted to know, yet my problem remains unanswered and unadressed, meanwhile
I have been given some unrelated and useless advice, so yes, you are
probably right.

Oh I understand. This is something like "My mind is made up. Don't confuse me
with the facts!"

No problem.
 
S

Simon Wigzell

I apologise for being cranky, just one of those days.

I have been progrmaming for 20 years and never met a language or structure
where you could assign a value to something but not get it back. My intent
here was to try to do something once, instead I ahve to do it 25 times. Oh
well, c'est la vie.

Again, I apologise for my cranky ungrateful comments to your well meaning
replies!
 
R

Roland Hall

in message
: On Thu, 02 Feb 2006 06:46:33 GMT, "Simon Wigzell" <[email protected]>
wrote:
: in <dVhEf.534342$ki.526673@pd7tw2no>
:
: >Well - I couldn't have been more explicit describing my problem and what
I
: >wanted to know, yet my problem remains unanswered and unadressed,
meanwhile
: >I have been given some unrelated and useless advice, so yes, you are
: >probably right.
:
: Oh I understand. This is something like "My mind is made up. Don't
confuse me
: with the facts!"
:
: No problem.

I like that response! Sorry Simon.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 
R

Roland Hall

in message : My website sends automatic emails from many (25) different places. I want
to
: send a second email by reading the parameters of the first one. I don't
want
: to have to repeat and maintain the assignment of the second email
: From,To,Subject fields so I am just using an include at each point in the
: code where I send an email:
:
: Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
: MyCDONTSMail.BodyFormat= 0
: MyCDONTSMail.MailFormat= 1
: MyCDONTSMail.From= (e-mail address removed)
: MyCDONTSMail.To= (e-mail address removed)
: MyCDONTSMail.Subject="some subject"
: MyCDONTSMail.Body= "some text":
: %>
: <!--#include file="SendFollowUpEmail.asp" -->
: <%
: MyCDONTSMail.Send
: set MyCDONTSMail=nothing
: -------------------------------------------------------------------------------
: The SendFollowUpEmail.asp just wants to take the From,To,Subject
parameters
: that are defined in the original email and add a different body:
:
: Set MyCDONTSMail2 = CreateObject("CDONTS.NewMail")
: MyCDONTSMail2.BodyFormat= 0
: MyCDONTSMail2.MailFormat= 1
: MyCDONTSMail2.From= MyCDONTSMail.From
: MyCDONTSMail2.To= MyCDONTSMail.To
: MyCDONTSMail2.Subject=MyCDONTSMail.Subject
: MyCDONTSMail2.Body= "some new text"
: MyCDONTSMail2.Send
: set MyCDONTSMail2=nothing
:
: It chokes on this:
:
: MyCDONTSMail2.From= MyCDONTSMail.From
:
: Object doesn't support this property or method: 'MyCDONTSMail.From'
:
: Seems to me MyCDONTSMail.From is only a string, why can't I retrieve its
: value? More to the point though - how can I retrieve its value?

There is a lot of ways to do it. As you said the values are not known so
just pass variables to it when the values are known. It could even be
session variables.

What you do it make it a subroutine.

sub sendMail(mailFrom, mailTo, mailSubject, mailBody)
Set MyCDONTSMail = CreateObject("CDONTS.NewMail")
MyCDONTSMail.BodyFormat = 0
MyCDONTSMail.MailFormat = 1
MyCDONTSMail.From = mailFrom
MyCDONTSMail.To = mailTo
MyCDONTSMail.Subject = mailSubject
MyCDONTSMail.Body= mailBody
end sub

With the follow up, just pass the different values to it.
sendMail "(e-mail address removed)", "(e-mail address removed)", "My Subject", "Here is my
message!"

If your message body is formatted, pass it as a variable.

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top