IIS ASP - javascript and email (part 2)

This is Interesting: Free IT Magazines  
Home > Archive > IIS ASP > February 2007 > javascript and email (part 2)





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author javascript and email (part 2)
rvj

2007-02-21, 7:16 pm


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


Anthony Jones

2007-02-21, 7:16 pm


"rvj" <rvj@rolemodels.net> wrote in message
news:ugcCeQfVHHA.1208@TK2MSFTNGP03.phx.gbl...
>
> 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




Dave Anderson

2007-02-22, 1:23 am

"Anthony Jones" wrote:
> 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.


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.



--
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.

Anthony Jones

2007-02-22, 7:19 am


"Dave Anderson" <NYRUMTPELVWH@spammotel.com> wrote in message
news:12tq5vbpti21443@corp.supernews.com...
> "Anthony Jones" wrote:
>
> 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.



rvj

2007-02-22, 7:19 am



Anyway - thanks to both of you !!!!


I finally managed to send an email !!!


"Anthony Jones" <Ant@yadayadayada.com> wrote in message
news:OVZ0EDmVHHA.1360@TK2MSFTNGP02.phx.gbl...
>
> "Dave Anderson" <NYRUMTPELVWH@spammotel.com> wrote in message
> news:12tq5vbpti21443@corp.supernews.com...
>
> 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.
>
>
>



rvj

2007-02-22, 7:19 am

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?.



"rvj" <rvj@rolemodels.net> wrote in message
news:uSw0zOnVHHA.4828@TK2MSFTNGP05.phx.gbl...
>
>
> Anyway - thanks to both of you !!!!
>
>
> I finally managed to send an email !!!
>
>
> "Anthony Jones" <Ant@yadayadayada.com> wrote in message
> news:OVZ0EDmVHHA.1360@TK2MSFTNGP02.phx.gbl...
>
>



Dave Anderson

2007-02-22, 1:18 pm

Anthony Jones wrote:
> 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?



--
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.


Anthony Jones

2007-02-22, 7:15 pm


"Dave Anderson" <NYRUMTPELVWH@spammotel.com> wrote in message
news:efZH7GoVHHA.4568@TK2MSFTNGP02.phx.gbl...
> Anthony Jones wrote:
>
> 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.




Dave Anderson

2007-02-23, 1:21 am

"Anthony Jones" wrote:
>
> 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.


Judge for yourself:
http://blogs.msdn.com/ericlippert/a.../22/430881.aspx

In particular, note Eric's acknowledgement that we often trade performance
for ease of use. I have absolutely no problem throwing ADO and CDO TYPELIB
declarations in my application roots because I never know A PRIORI if/where
I will need them.



--
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.

Anthony Jones

2007-02-23, 7:21 am


"Dave Anderson" <NYRUMTPELVWH@spammotel.com> wrote in message
news:12tso4jjo2lls5f@corp.supernews.com...
> "Anthony Jones" wrote:
>
> Judge for yourself:
> http://blogs.msdn.com/ericlippert/a.../22/430881.aspx
>


A very interesting series of articles, thanks.

> In particular, note Eric's acknowledgement that we often trade performance
> for ease of use. I have absolutely no problem throwing ADO and CDO TYPELIB
> declarations in my application roots because I never know A PRIORI

if/where
> I will need them.


Ok I can see that point of view also make sense.



Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com