CDONTS NewMail

E

Earl Partridge

If there's a newgroup for this subject, please point me to it...
Is it possible to set the font size of the body of the text?
Earl
 
A

Anthony Jones

Earl Partridge said:
If there's a newgroup for this subject, please point me to it...
Is it possible to set the font size of the body of the text?

First ditch CDONTS (its deprecated) and use CDOSYS instead. Here is an
exampel of sending an
email with CDOSYS:-

Const cdoSendUsingMethod =
"http://schemas.microsoft.com/cdo/configuration/sendusing"
Const cdoSMTPServer =
"http://schemas.microsoft.com/cdo/configuration/smtpserver"
Const cdoSMTPServerPickupDirectory =
"http://schemas.microsoft.com/cdo/configuration/smtpserverpickupdirectory"
Const cdoSMTPServerPort =
"http://schemas.microsoft.com/cdo/configuration/smtpserverport"

Const cdoSendUsingPickup = 1
Const cdoSendUsingPort = 2

Dim oMsg : Set oMsg = CreateObject("CDO.Message")
Dim oConfig : Set oConfig = CreateObject("CDO.Configuration")

With oConfig.Fields
.Item(cdoSendUsingMethod) = cdoSendUsingPort
.Item(cdoSMTPServer) = "mysmtp.myserver.com"
.Item(cdoSMTPServerPort) = 25
.Update
End With

oMsg.From = "Me <[email protected]>"
oMsg.To = "Bloke <[email protected]>"
oMsg.Subject = "Test"
oMsg.HTMLBody = "<html><body style="font-size:14pt">Hello
World</body></html>"
Set oMsg.Configuration = oConfig

oMsg.Send


Note the HTMLBody uses a style that defines the font size.

Of course this assumes you aren't asking how to make the size of font in a
plain text message the bigger. The answer to that would be; you can't use a
HTMLBody instead.
 
O

Old Pedant

A goof in that, Anthony:

oMsg.HTMLBody = "<html><body style="font-size:14pt">Hello
World</body></html>"

Ummm...that NEEDS to be

oMsg.HTMLBody = "<html><body style=""font-size:14pt"">Hello
World</body></html>"

Doubled quotes to embed them, of course.
 
E

Earl Partridge

Thanks, would I need to get my hosting service to do any configuration
change to accept CDOSYS?
Earl
 
M

Mike Brind [MVP]

If your hoster is using Win 2k or above, then no. CDO became the default
mailing component from Win 2k. In fact, you are more likely to have
problems getting them to set up CDONTS.

--
Mike Brind
Microsoft MVP - ASP/ASP.NET


Earl Partridge said:
Thanks, would I need to get my hosting service to do any configuration
change to accept CDOSYS?
Earl
 
E

Earl Partridge

I already have CDONTS working with my host's server. I was just trying to
figure out how change the font size in CDONTS. If I switch to CDOSYS, do I
need to build in those 6 Const lines?
Earl


Mike Brind said:
If your hoster is using Win 2k or above, then no. CDO became the default
mailing component from Win 2k. In fact, you are more likely to have
problems getting them to set up CDONTS.
 
O

Old Pedant

I already have CDONTS working with my host's server. I was just trying to
figure out how change the font size in CDONTS.

Oh, well, then it's easy: But you can *ONLY* specify font size *IF* you
sent HTML Email. You can't do it if you are sending plain text email.

So if your courrent mail body looks something like:
mail.body = "Hello, " & name & vbNewLine _
& "Thanks for your inquiry." & vbNewLine _
& "We'll get back to you ASAP."

You'll need to start using HTML line breaks, etc, in place of just the
newlines (or CRLF or whatever you are using), and *TELL* CDONTS that you are
using HTML, thus:

mail.MailFormat = 0 ' specifies HTML
mail.BodyFormat = 0 ' ditto
mail.body = "Hello, " & name & "<p>" & vbNewLine _
& "Thanks for your inquiry.<br/>" & vbNewLine _
& "We'll get back to you ASAP.<p>"

You might want to check this out:
http://www.aspfaqs.com/aspfaqs/ShowCategory.asp?CatID=10
 
A

Anthony Jones

Old Pedant said:
A goof in that, Anthony:

oMsg.HTMLBody = "<html><body style="font-size:14pt">Hello
World</body></html>"

Ummm...that NEEDS to be

oMsg.HTMLBody = "<html><body style=""font-size:14pt"">Hello
World</body></html>"

Doubled quotes to embed them, of course.


Oooops. Nothing is so easy that it doesn't need testing. ;)
 
A

Anthony Jones

Neil Gould said:
Hi Earl,

Recently said:
[...] If I switch to CDOSYS, do I need to build in those 6 Const lines?
Earl
I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including them
caused the mail to fail. CDOSYS works fine without them. I suspect this is
an ISP-specific issue, but don't know for sure.

In what way did it fail?

Are you using the identifiers such as cdoSendUsingMethod without defining
them (this is possible in some circumstances)?

OR

Does your original code not manipulate the configuration object at all
(again in some circumstances the ISP can ensure the configuration object is
already set up).
 
N

Neil Gould

Hi Earl,

Recently said:
[...] If I switch to CDOSYS, do I need to build in those 6 Const lines?
Earl
I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including them
caused the mail to fail. CDOSYS works fine without them. I suspect this is
an ISP-specific issue, but don't know for sure.

Neil
 
N

Neil Gould

Recently said:
Neil Gould said:
Hi Earl,

Recently said:
[...] If I switch to CDOSYS, do I need to build in those 6 Const
lines? Earl
I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including
them caused the mail to fail. CDOSYS works fine without them. I
suspect this is an ISP-specific issue, but don't know for sure.

In what way did it fail?
The email didn't get sent. I consider that a failure for an email routine.
;-)

Removed the lines, and all is (almost) well.

One thing I wanted to know is why the references to a server external to
the ISP?
Are you using the identifiers such as cdoSendUsingMethod without
defining them (this is possible in some circumstances)?

OR

Does your original code not manipulate the configuration object at all
(again in some circumstances the ISP can ensure the configuration
object is already set up).
I think this may be the case, and the failure could have been a conflict
in the Method definitions, but I couldn't tell from the "outside". It's
not the only quirk with the ISP. ;-)

Neil
 
A

Anthony Jones

Neil Gould said:
Recently said:
Neil Gould said:
Hi Earl,

Recently, Earl Partridge <[email protected]> posted:

[...] If I switch to CDOSYS, do I need to build in those 6 Const
lines? Earl

I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including
them caused the mail to fail. CDOSYS works fine without them. I
suspect this is an ISP-specific issue, but don't know for sure.

In what way did it fail?
The email didn't get sent. I consider that a failure for an email routine.
;-)

I was wondering if you got some kind of error from the page doing the
sending. If not then CDOSYS is connecting to an SMTP server and
successfully getting the message to it. Where it goes after that who knows?
Removed the lines, and all is (almost) well.

One thing I wanted to know is why the references to a server external to
the ISP?

I think this may be the case, and the failure could have been a conflict
in the Method definitions, but I couldn't tell from the "outside". It's
not the only quirk with the ISP. ;-)

Try removing the code that manipulates the Configuration thereby using the
default configuration the message object comes with.
 
N

Neil Gould

Recently said:
Neil Gould said:
Recently said:
Hi Earl,

Recently, Earl Partridge <[email protected]> posted:

[...] If I switch to CDOSYS, do I need to build in those 6 Const
lines? Earl

I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including
them caused the mail to fail. CDOSYS works fine without them. I
suspect this is an ISP-specific issue, but don't know for sure.

In what way did it fail?
The email didn't get sent. I consider that a failure for an email
routine. ;-)

I was wondering if you got some kind of error from the page doing the
sending. If not then CDOSYS is connecting to an SMTP server and
successfully getting the message to it. Where it goes after that who
knows?
No error message, no delivery.
Try removing the code that manipulates the Configuration thereby
using the default configuration the message object comes with.
Well, the email routine works if *all* of the cdo lines are omitted. What
will I gain by putting them back?

Neil
 
A

Anthony Jones

Neil Gould said:
Recently said:
Neil Gould said:
Recently, Anthony Jones <[email protected]> posted:

Hi Earl,

Recently, Earl Partridge <[email protected]> posted:

[...] If I switch to CDOSYS, do I need to build in those 6 Const
lines? Earl

I, too, would like to know more about those const lines.

Having just re-written our email routines, I found that including
them caused the mail to fail. CDOSYS works fine without them. I
suspect this is an ISP-specific issue, but don't know for sure.

In what way did it fail?

The email didn't get sent. I consider that a failure for an email
routine. ;-)

I was wondering if you got some kind of error from the page doing the
sending. If not then CDOSYS is connecting to an SMTP server and
successfully getting the message to it. Where it goes after that who
knows?
No error message, no delivery.
Try removing the code that manipulates the Configuration thereby
using the default configuration the message object comes with.
Well, the email routine works if *all* of the cdo lines are omitted. What
will I gain by putting them back?

You will have to define "*all* of the cdo lines".

If you are refering to removing some lines from the code I posted you should
understand that all the code was CDO. Do you mean just removing the Const
definitions, or lines affecting the configuration or something else? Can
you post a small example of code you have now working?
 
N

Neil Gould

(Mostly snipped for brevity)


Recently said:
You will have to define "*all* of the cdo lines".
I guess I was being over-inclusive. ;-)
If you are refering to removing some lines from the code I posted you
should understand that all the code was CDO. Do you mean just
removing the Const definitions, or lines affecting the configuration
or something else? Can you post a small example of code you have now
working?
Sure. This is all that is needed to send mail from our particular ISP:

Set objMail= Server.CreateObject("CDO.Message")
With objMail
.From = Session.Contents.Item("From")
.To = MailData("PrimEmail")
.Subject = Session.Contents.Item("Subj")
.TextBody = Session.Contents.Item("Msg")
IF Trim(Session.Contents.Item("Attach")) > "" THEN
.AddAttachment(Session.Contents.Item("Attach"))
END IF
.Send
End With
Set objMail = Nothing

So... my question is about the lines in your example:
What is gained by adding them, or risked by omitting them?

Best,

Neil
 
A

Anthony Jones

Neil Gould said:
(Mostly snipped for brevity)




I guess I was being over-inclusive. ;-)

Sure. This is all that is needed to send mail from our particular ISP:

Set objMail= Server.CreateObject("CDO.Message")
With objMail
.From = Session.Contents.Item("From")
.To = MailData("PrimEmail")
.Subject = Session.Contents.Item("Subj")
.TextBody = Session.Contents.Item("Msg")
IF Trim(Session.Contents.Item("Attach")) > "" THEN
.AddAttachment(Session.Contents.Item("Attach"))
END IF
.Send
End With
Set objMail = Nothing

So... my question is about the lines in your example:

What is gained by adding them, or risked by omitting them?


Your ISP has used server extensions to specify default values for
CDO.Configuration settings. Hence the default configuration object that the
CDO.Message object is given on creation has the above settings already so
your code need not worry about them.

I included them because on a vanillia IIS server these settings are not
defaulted.

Gains you can achieve by using them is control of extactly how an email gets
sent. Bear in mind that many IIS are managed by the site owners rather than
an ISP and therefor greater control is available. I have clients who want
to be able to dispatch emails via pickup folder. Not something you
typically do on an ISP hosted site.

The risks are that the ISP may not support the changes you make to the
configuration, for example, the may insist that all SMTP traffic go out via
their own SMTP server.

My advice is if the ISP has configured the mail settings for the site for
you, then use those, it keeps your code simple and is more likely to work.
On the downside if you choose to move your code to another ISP you may find
you need to add more code to get it work. If you use CDO from more than
one page consider wrapping up the CDO code in class and place it in an
include file.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top