Works in VBS, why not JS?! 
Author Message
 Works in VBS, why not JS?!

Man... this is driving me crazy. I have been messing with this for 2 hours, looked at tons of samples, read everything in my reference and still it doesn't make sense.

I have a client side script that will create an outlook.application mail item, then send it. I have this working in VBS, I want to use jscript so I made a version in jscript. For some reason, it says that this line:
//
//
b = a.CreateItem( olMailItem )

is undefined! I don't see why, I am creating a with this:
//
//
a = new ActiveXObject('outlook.application');

that works fine. Here is my entire VBS function:
'
'
'-----------------------------------------------
function SendMail

    dim a
    dim b

    set a = createobject( "outlook.application" )
    set b = a.createitem( olMailitem )

        Subj = CurrDoc
        body = "Look at this file: " & "http://" &  ServName & CurrDoc

    b.subject = prompt("Subject:", "Take a look at this file")
    b.body = "<b>This is a test</b>"
    b.send()

        alert("message sent")

end function
'
'
'---------------------------------------------------]
that works just fine, here is the js equivalent:
//
//
//---------------------------------------------------
function EmailLink() {
var b
    a = new ActiveXObject('outlook.application');
        alert(a);
    b = a.CreateItem( olMailItem );

        Subj = 'K2 Search wants you to look at a file!';
        body = 'This is a test';
    b.to = dst;
    b.subject = subj;
    b.body = body;

    b.send();

Quote:
}

//
//
//-----------------------------------------------------]

If this makes any sense to any of you, I WOULD LOVE TO HEAR IT. I am feeling pretty defeated now, so any help would be great.

Thanks-

Steve

*** Sent via Developersdex http://www.*-*-*.com/ ***
Don't just participate in USENET...get rewarded for it!



Sun, 14 Dec 2003 14:53:31 GMT  
 Works in VBS, why not JS?!
Steve,

Have you tried using a zero instead of the constant "olMailItem" - it's
possible that VB recognises the Outlook constants but JScript doesn't...

Tony.


Quote:
> Man... this is driving me crazy. I have been messing with this for 2

hours, looked at tons of samples, read everything in my reference and still
it doesn't make sense.
Quote:

> I have a client side script that will create an outlook.application mail

item, then send it. I have this working in VBS, I want to use jscript so I
made a version in jscript. For some reason, it says that this line:
Quote:
> //
> //
> b = a.CreateItem( olMailItem )

> is undefined! I don't see why, I am creating a with this:
> //
> //
> a = new ActiveXObject('outlook.application');

> that works fine. Here is my entire VBS function:
> '
> '
> '-----------------------------------------------
> function SendMail

>     dim a
>     dim b

>     set a = createobject( "outlook.application" )
>     set b = a.createitem( olMailitem )

> Subj = CurrDoc
> body = "Look at this file: " & "http://" &  ServName & CurrDoc

>     b.subject = prompt("Subject:", "Take a look at this file")
>     b.body = "<b>This is a test</b>"
>     b.send()

> alert("message sent")

> end function
> '
> '
> '---------------------------------------------------]
> that works just fine, here is the js equivalent:
> //
> //
> //---------------------------------------------------
> function EmailLink() {
> var b
>     a = new ActiveXObject('outlook.application');
> alert(a);
>     b = a.CreateItem( olMailItem );

> Subj = 'K2 Search wants you to look at a file!';
> body = 'This is a test';
>     b.to = dst;
>     b.subject = subj;
>     b.body = body;

>     b.send();
> }
> //
> //
> //-----------------------------------------------------]

> If this makes any sense to any of you, I WOULD LOVE TO HEAR IT. I am

feeling pretty defeated now, so any help would be great.

- Show quoted text -

Quote:

> Thanks-

> Steve

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Sun, 14 Dec 2003 21:43:13 GMT  
 Works in VBS, why not JS?!
Hey Tony,

Yeah, I have tried that. Plus, I have seen examples on the web where people have done exactly what I am doing, so there is some tiny little thing that I am missing

Thanks for the suggestion-

Steve

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!



Sun, 14 Dec 2003 22:41:15 GMT  
 Works in VBS, why not JS?!
Hi Tony,

No, I haven't tried that, but I have seen many examples
where, using javascript, the create the mail item like I
have.

Thanks for the suggestion though!

SK

Quote:
>-----Original Message-----
>Steve,

>Have you tried using a zero instead of the

constant "olMailItem" - it's
Quote:
>possible that VB recognises the Outlook constants but
JScript doesn't...

>Tony.



>> Man... this is driving me crazy. I have been messing
with this for 2
>hours, looked at tons of samples, read everything in my
reference and still
>it doesn't make sense.

>> I have a client side script that will create an

outlook.application mail
Quote:
>item, then send it. I have this working in VBS, I want to
use jscript so I
>made a version in jscript. For some reason, it says that
this line:
>> //
>> //
>> b = a.CreateItem( olMailItem )

>> is undefined! I don't see why, I am creating a with
this:
>> //
>> //
>> a = new ActiveXObject('outlook.application');

>> that works fine. Here is my entire VBS function:
>> '
>> '
>> '-----------------------------------------------
>> function SendMail

>>     dim a
>>     dim b

>>     set a = createobject( "outlook.application" )
>>     set b = a.createitem( olMailitem )

>> Subj = CurrDoc
>> body = "Look at this file: " & "http://" &  ServName &
CurrDoc
>>     b.to = prompt("Who do you want to send this


- Show quoted text -

Quote:
>>     b.subject = prompt("Subject:", "Take a look at this
file")
>>     b.body = "<b>This is a test</b>"
>>     b.send()

>> alert("message sent")

>> end function
>> '
>> '
>> '---------------------------------------------------]
>> that works just fine, here is the js equivalent:
>> //
>> //
>> //---------------------------------------------------
>> function EmailLink() {
>> var b
>>     a = new ActiveXObject('outlook.application');
>> alert(a);
>>     b = a.CreateItem( olMailItem );

>> Subj = 'K2 Search wants you to look at a file!';
>> body = 'This is a test';
>>     b.to = dst;
>>     b.subject = subj;
>>     b.body = body;

>>     b.send();
>> }
>> //
>> //
>> //-----------------------------------------------------]

>> If this makes any sense to any of you, I WOULD LOVE TO
HEAR IT. I am
>feeling pretty defeated now, so any help would be great.

>> Thanks-

>> Steve

>> *** Sent via Developersdex http://www.developersdex.com
***
>> Don't just participate in USENET...get rewarded for it!

>.



Mon, 15 Dec 2003 00:07:18 GMT  
 Works in VBS, why not JS?!
I had the same problem with ADSI on the web server where I could not get a JS version to work although the VBS version worked. I think it has to do with the automation process.
Quote:

> Man... this is driving me crazy. I have been messing with this for 2 hours, looked at tons of samples, read everything in my reference and still it doesn't make sense.

> I have a client side script that will create an outlook.application mail item, then send it. I have this working in VBS, I want to use jscript so I made a version in jscript. For some reason, it says that this line:
> //
> //
> b = a.CreateItem( olMailItem )

> is undefined! I don't see why, I am creating a with this:
> //
> //
> a = new ActiveXObject('outlook.application');

> that works fine. Here is my entire VBS function:
> '
> '
> '-----------------------------------------------
> function SendMail

>     dim a
>     dim b

>     set a = createobject( "outlook.application" )
>     set b = a.createitem( olMailitem )

> Subj = CurrDoc
> body = "Look at this file: " & "http://" &  ServName & CurrDoc

>     b.subject = prompt("Subject:", "Take a look at this file")
>     b.body = "<b>This is a test</b>"
>     b.send()

> alert("message sent")

> end function
> '
> '
> '---------------------------------------------------]
> that works just fine, here is the js equivalent:
> //
> //
> //---------------------------------------------------
> function EmailLink() {
> var b
>     a = new ActiveXObject('outlook.application');
> alert(a);
>     b = a.CreateItem( olMailItem );

> Subj = 'K2 Search wants you to look at a file!';
> body = 'This is a test';
>     b.to = dst;
>     b.subject = subj;
>     b.body = body;

>     b.send();
> }
> //
> //
> //-----------------------------------------------------]

> If this makes any sense to any of you, I WOULD LOVE TO HEAR IT. I am feeling pretty defeated now, so any help would be great.

> Thanks-

> Steve

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Mon, 15 Dec 2003 19:31:28 GMT  
 Works in VBS, why not JS?!
An undefined variable in VBScript (in the absence of Option Explicit) will take the value 0 or an
empty string depending on the context in which it's used.  In JScript, an undefined variable won't
do that.

--
Michael Harris
Microsoft.MVP.Scripting
--

Please do not email questions - post them to the newsgroup instead.
--

Quote:

> Hey Tony,

> Yeah, I have tried that. Plus, I have seen examples on the web where people have done exactly what

I am doing, so there is some tiny little thing that I am missing
Quote:

> Thanks for the suggestion-

> Steve

> *** Sent via Developersdex http://www.developersdex.com ***
> Don't just participate in USENET...get rewarded for it!



Tue, 16 Dec 2003 09:33:27 GMT  
 Works in VBS, why not JS?!

Quote:
> Hi Tony,

> No, I haven't tried that, but I have seen many examples
> where, using javascript, the create the mail item like I
> have.

Hi,

They probably declared the constant somewhere, maybe in an include script.
If you substitute 0 (or whatever the value of the constant is), it should
work.

Note that the Outlook 2000 security patch (and Outlook XP) don't allow you
to do this from script without responding to a dialog box.

You also need to correct the case of your "Subj" variable, and declaring it
wouldn't hurt :-)

Peter

--

JScript .NET / VSA Runtime Program Manager
Please post all questions to the group. Thanks.



Thu, 18 Dec 2003 07:14:05 GMT  
 
 [ 7 post ] 

 Relevant Pages 

1. VBS works, JS doesnt, pls, Why

2. Help...Why my vbs not working Properly.

3. !?? WScript.Echo works different in vbs and js ?

4. UTF-8 Encoded .JS script not working in Netscape

5. JS works on Netscape but not on IE

6. ActiveInspector.CurrentItem why not work ?

7. Why is this source not working

8. Why the HELL does this not work??

9. Why is this not working

10. why it does not work ?

11. Rs.Addnew will not work, WHY?

12. Why does this work in IE5.0 but not IE4.0

 

 
Powered by phpBB® Forum Software