Calling a vbscript from Java?

Hello,

I wish to call a vb script from a Java class. The Vb script is responsible for sending an email to a recipient after they have filled a form out in a java GUI.

I have never used native methods before and was wondering if any of you people have some experience in this type of collaboration. I want to be able pass in a variable of an email address to the Vb script and then it will email the recipient. I have had a look on Google but there isn't anything specific to my needs. Most of the tutorials focus on C and C++ and I believe with these languages you have to place appropriate files in the Syste32 folder of the local machine. I really just want to be able to include this in my java project folder as it will be used by multiple users and it is not practical for everyone to have to place this file there themselves?

In short, is this possible?

and if you have time, can you explain how to approach this?

Thanks

Mike

[975 byte] By [kikemellya] at [2007-11-26 16:22:43]
# 1
Why not ditch the vb script and just use JavaMail?
bckrispia at 2007-7-8 22:46:30 > top of Java-index,Java Essentials,New To Java...
# 2

If you can run this VBScript thing from the command line, passing the e-mail address as a parameter or whatever, then just do that. Use Runtime.getRuntime().exec() and read the JavaWorld article about "traps" in this method that everybody posts here when questions are asked about the feature but that I can't be bothered to google for right at the moment.

DrClapa at 2007-7-8 22:46:30 > top of Java-index,Java Essentials,New To Java...
# 3

I thought it might be easier with a vb script as the mail client will be outlook and the code for sending a mail this way is pretty short and straightforward. With javamail I would need to download the libraries and then include them in my project. This code will be deployed on remote machines with a local mail server which I don't have access to on my machine. This means I cant test it before sending it off. The vb script works fine, as I used it on the local network. I just need a way of passing in a value and automating the mail from this script via my Java code.

kikemellya at 2007-7-8 22:46:30 > top of Java-index,Java Essentials,New To Java...
# 4
Sounds like a plan!I would imagine it should be possible to run this script from a prompt so maybe I am in business. Thank you doc!
kikemellya at 2007-7-8 22:46:30 > top of Java-index,Java Essentials,New To Java...
# 5

> I thought it might be easier with a vb script as the

> mail client will be outlook and the code for sending

> a mail this way is pretty short and straightforward.

Yeah... we have some VB programs (not VBScript, that runs in the browser if I'm not mistaken) that use a tiny amount of code to send e-mails from a PC. But our PC people came in and wanted to upgrade Outlook 2000 to something newer, and the newer thing had new security features that required somebody to click on a button okaying the e-mail.

This didn't work for us because our system was supposed to run unattended, so we backed out and reloaded Outlook 2000. We're trying to phase that out anyway. But I guess it would be okay for you because you have somebody sitting at the machine when the e-mail sending happens.

DrClapa at 2007-7-8 22:46:30 > top of Java-index,Java Essentials,New To Java...