javascript and email (part 2)

R

rvj

Ive come a cross another issue when trying to convert CDO VB to JS

The basic send generated the SendUsing configuration is invalid which I
understand means I have to specify the smpt server (amongst other
things)using the configuration object

**********************************

Set objConfig = Server.CreateObject("CDO.Configuration")
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="smtp.server.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x"
objConfig.Fields(cdoSendPassword) = "xxxxxxxx"
Set objMail.Configuration = objConfig

************************

so do I assume that the following COM syntax should work with JS and
are the cdoconstants script independent ?

***********************


var objConfig = Server.CreateObject("CDO.Configuration")
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="smtp.server.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x"
objConfig.Fields(cdoSendPassword) = "xxxxxxxx"
objConfig.Fields.Update ()

var objMail.Configuration = objConfig
 
A

Anthony Jones

rvj said:
Ive come a cross another issue when trying to convert CDO VB to JS

The basic send generated the SendUsing configuration is invalid which I
understand means I have to specify the smpt server (amongst other
things)using the configuration object

**********************************

Set objConfig = Server.CreateObject("CDO.Configuration")
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="smtp.server.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x"
objConfig.Fields(cdoSendPassword) = "xxxxxxxx"
Set objMail.Configuration = objConfig

************************

so do I assume that the following COM syntax should work with JS and
are the cdoconstants script independent ?

***********************


var objConfig = Server.CreateObject("CDO.Configuration")
objConfig.Fields(cdoSendUsingMethod) = cdoSendUsingPort
objConfig.Fields(cdoSMTPServer)="smtp.server.co.uk"
objConfig.Fields(cdoSMTPServerPort)=25
objConfig.Fields(cdoSMTPAuthenticate)=cdoBasic
objConfig.Fields(cdoSendUserName) = "mxxxxxxxx-x"
objConfig.Fields(cdoSendPassword) = "xxxxxxxx"
objConfig.Fields.Update ()

var objMail.Configuration = objConfig

You are going to need to find the constant and enumeration values for all
the cdo members you want to use and create variables to hold them so that
code such as the above will work. For example

var cdo = {}

cdo.SendUsingMethod =
'http://schemas.microsoft.com/cdo/configuration/sendusing'
cdo.SMTPServer = 'http://schemas.microsoft.com/cdo/configuration/smtpserver'
cdo.SendUsingPort = 2

objConfig.Fields(cdo.SendUsingMethod) = cdo.SendUsingPort
 
A

Anthony Jones

Dave Anderson said:
No, he will not need to do that. He can use a TYPELIB declaration in
global.asa and drive right on as in his example.

You're quite right. I was under the impression for some reason that only
worked in the VBScript environment but it does indeed work with JScript just
as well. Eg.:-

<%@language=JScript%>
<!-- METADATA NAME="Microsoft CDO For Exchange 2000 Library"
TYPE="TypeLib" UUID="{CD000000-8B95-11D1-82DB-00C04FB1625D}" -->
<%
Response.Write(cdoSMTPServer)
%>

If only one or two pages need the type library it might be better to just
place the METADATA directive in just those pages rather than in the
global.asa.
 
R

rvj

PS

Just out of interest does anyone know if its possible to turn off CDO
sender address checking (.From property) ?

From
E-mail address of the primary author of the message. This property is
optional; if left blank, the From property will be set to the value of the
Sender property, assuming a value for this property has been configured. If
neither the From property nor the Sender property is configured, the script
will fail.



It only appears to accept an "email type" syntax rather than plain text.
However most of the emails I recieve tend to have the From content in plain
text so I assume this is possible?.
 
D

Dave Anderson

Anthony said:
If only one or two pages need the type library it might be
better to just place the METADATA directive in just those
pages rather than in the global.asa.

Better how?

I ask because it is not clear to me that there is a performance issue. After
all, Application_OnStart() is in global.asa, and it does not get used by
every page/request, so it occurs to me that the TYPELIB may simply be loaded
with the application. I understand that using the TYPELIB is more costly
than adovbs.inc (or equivalent) at runtime, but that would seem to be true
whether you put it directly in your script or in the global.asa, wouldn't
it?
 
A

Anthony Jones

Dave Anderson said:
Better how?

It just doesn't make sense to modify a global resource for the benefit of
just one or two pages.
I ask because it is not clear to me that there is a performance issue. After
all, Application_OnStart() is in global.asa, and it does not get used by
every page/request, so it occurs to me that the TYPELIB may simply be loaded
with the application. I understand that using the TYPELIB is more costly
than adovbs.inc (or equivalent) at runtime, but that would seem to be true
whether you put it directly in your script or in the global.asa, wouldn't
it?

I'm surprised to hear that. I would have thought the use of adovbs.inc was
more expensive but I've never really looked into.
 
A

Anthony Jones

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,773
Messages
2,569,594
Members
45,117
Latest member
Matilda564
Top