javascript and email (part 2)
javascript and email (part 2)
am 21.02.2007 21:08:54 von 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
Re: javascript and email (part 2)
am 21.02.2007 23:16:14 von Anthony Jones
"rvj" 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
Re: javascript and email (part 2)
am 22.02.2007 05:11:13 von Dave Anderson
"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.
Re: javascript and email (part 2)
am 22.02.2007 10:06:39 von Anthony Jones
"Dave Anderson" wrote in message
news:12tq5vbpti21443@corp.supernews.com...
> "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.
>
>
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%>
<%
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.
Re: javascript and email (part 2)
am 22.02.2007 12:22:10 von rvj
Anyway - thanks to both of you !!!!
I finally managed to send an email !!!
"Anthony Jones" wrote in message
news:OVZ0EDmVHHA.1360@TK2MSFTNGP02.phx.gbl...
>
> "Dave Anderson" wrote in message
> news:12tq5vbpti21443@corp.supernews.com...
>> "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.
>>
>>
>
> 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%>
>
> <%
> 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.
>
>
>
Re: javascript and email (part 2)
am 22.02.2007 13:18:04 von 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?.
"rvj" wrote in message
news:uSw0zOnVHHA.4828@TK2MSFTNGP05.phx.gbl...
>
>
> Anyway - thanks to both of you !!!!
>
>
> I finally managed to send an email !!!
>
>
> "Anthony Jones" wrote in message
> news:OVZ0EDmVHHA.1360@TK2MSFTNGP02.phx.gbl...
>>
>> "Dave Anderson" wrote in message
>> news:12tq5vbpti21443@corp.supernews.com...
>>> "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.
>>>
>>>
>>
>> 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%>
>>
>> <%
>> 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.
>>
>>
>>
>
>
Re: javascript and email (part 2)
am 22.02.2007 14:02:37 von Dave Anderson
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.
Re: javascript and email (part 2)
am 23.02.2007 00:50:17 von Anthony Jones
"Dave Anderson" wrote in message
news:efZH7GoVHHA.4568@TK2MSFTNGP02.phx.gbl...
> 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?
>
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.
Re: javascript and email (part 2)
am 23.02.2007 04:33:27 von Dave Anderson
"Anthony Jones" wrote:
>> 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.
Judge for yourself:
http://blogs.msdn.com/ericlippert/archive/2005/06/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.
Re: javascript and email (part 2)
am 23.02.2007 10:20:22 von Anthony Jones
"Dave Anderson" wrote in message
news:12tso4jjo2lls5f@corp.supernews.com...
> "Anthony Jones" wrote:
> >> 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.
>
> Judge for yourself:
> http://blogs.msdn.com/ericlippert/archive/2005/06/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.