Runtime.getRuntime() question

N

Niall

I have my app opening up outlook express useing
Runtime.getRuntime().exec(root) command root being the address of outlook
express, what I was wondering now if I could automatically insert the
e-mail address into the e-mail address field in outlook, and then a
message?

This would be a great help and I would would greatly apreseate it.
 
T

Thomas Schodt

Niall said:
I have my app opening up outlook express useing
Runtime.getRuntime().exec(root) command root being the address of outlook
express, what I was wondering now if I could automatically insert the
e-mail address into the e-mail address field in outlook, and then a
message?

I would suggest what you are attempting is not the best solution.

What about using Java to send the email?

Eg.

http://mindprod.com/jgloss/javamail.html
 
C

Christophe Vanfleteren

Niall said:
I have my app opening up outlook express useing
Runtime.getRuntime().exec(root) command root being the address of outlook
express, what I was wondering now if I could automatically insert the
e-mail address into the e-mail address field in outlook, and then a
message?

This would be a great help and I would would greatly apreseate it.

This is not a runtime.exec question, but an Outlook question.
I suggest you ask some Microsoft/Windows group what arguments you can use
with Outlook.

But do you really need Outlook? Have you looked at Javamail?
 
T

Thomas Weidenfeller

Thomas said:
I would suggest what you are attempting is not the best solution.

What about using Java to send the email?

We told him last time he asked that question. He didn't care.

/Thomas
 
T

Thomas Schodt

Thomas said:
We told him last time he asked that question. He didn't care.

LOL; if he thinks that would be too much hassle I guess there's no point
in telling him about Java Robot...
 
L

Liz

Niall said:
I have my app opening up outlook express useing
Runtime.getRuntime().exec(root) command root being the address of outlook
express, what I was wondering now if I could automatically insert the
e-mail address into the e-mail address field in outlook, and then a
message?

This would be a great help and I would would greatly apreseate it.

It is probably some parameter you can set. I
think in the past I used -s <string> to set the subject.
Play with it a little or google for stuff about outlook.
 
R

Roedy Green

What about using Java to send the email?

Look at the JavaMail tutorial, not the JavaDoc. The JavaDoc is
terrifying. The tutorial will show how you can do this whole project
in half a page of code. AND you have the advantage it will run faster,
run without requiring Outlook, and will run on any platform.


The only disadvanatage is that Outlook will have no record of the
outgoing mail.
 
R

Roedy Green

The only disadvanatage is that Outlook will have no record of the
outgoing mail.

Javamail has one other disadvantage. You have to configure it with the
same gobblegook you have to configure any email client program.

mailserver name, id, password, protocol, authentication...
 
C

Chris Uppal

Roedy said:
Javamail has one other disadvantage. You have to configure it with the
same gobblegook you have to configure any email client program.

Agreed. And that means that you have to get that data from your /user/ --
which will often be, let's say, challenging for them.

I really don't see why so many people want to push the Javamail solution. For
the kind of application that I understand the OP to have in mind:

Initiate the process of sending an email with the relevant fields already
filled in.

(note, "initiate the process of sending an email" not "send an email")

it seems that launching the user's own email program with the right parameters
is not only a good solution, it is the /best/ solution. Javamail (if I've
understood the OP correctly) is a very /bad/ fit to these requirements.

Ideally (since this is restricted to Windows) you'd want to be able to tell the
system to ShellExecute() with the "mailto:[email protected]" URL. Unfortunately you
can't just pass a mailto: URL to Runtime.() (or at least, I couldn't make it
work), and I don't know of any other way to achieve the same effect.

Possibly (and in the absence of an already existing program that'll do it for
you_ the OP could use a small helper Windows program written in C that does a
ShellExecute() of its argument. He could then call that from Runtime.exec(),
and it would in turn cause Windows to find/launch the user's preferred email
program.

-- chris
 
R

Roedy Green

Ideally (since this is restricted to Windows) you'd want to be able to tell the
system to ShellExecute() with the "mailto:[email protected]" URL. Unfortunately you
can't just pass a mailto: URL to Runtime.() (or at least, I couldn't make it
work), and I don't know of any other way to achieve the same effect.

In an ideal universe, there should be a file type that when associated
with an email program uses that file to send an email. The file would
contain the headers and text of the message. Then all you would have
to do is create such a file e.g. xxxx.email and then exec it and let
he OS deliver it to the default email program.

If such a thing does not exist, you probably could cook up a C program
that fielded such files and passed them on with DDE or whatever
gobbledegook the local platform requires.
 
R

Roedy Green

In an ideal universe, there should be a file type that when associated
with an email program uses that file to send an email. The file would
contain the headers and text of the message. Then all you would have
to do is create such a file e.g. xxxx.email and then exec it and let
he OS deliver it to the default email program.

Perhaps how about setting up an interface for sending a mail via the
local mail client. In many cases this is what you want for ease of
configuring and for a permanent record of the outgoing message.

It can then be implemented with JNI on various platforms for the major
email clients. Worse comes to worse the implementation just steals
the configuration info from the client and sends via Javamail.

It might even look just like JavaMail, but with a different Transport.
This way you can easily offer both options with the same code or
change your mind later with ease.

If you defined the interface and implemented even one client in JNI in
one platform, you might start a trend.

you would build the message same as in JavaMail, with code like this:

Session session = Session.getDefaultInstance( props, null );
session.setDebug( CustConfig.debugging );
MimeMessage sm = new MimeMessage( session );
sm.setSentDate( new java.util.Date() /* now */ );
sm.setFrom( from );
Address[] replyTos = rm.getReplyTo();
if ( replyTos != null && replyTos.length > 0 )
{
sm.setReplyTo( replyTos );
}
sm.setRecipient( Message.RecipientType.TO,"(e-mail address removed)");
sm.setHeader( "X-Mailer","Canadian Mind Products bulk mailer" );
sm.setSubject( subject );
...

// new gismo, everything else just like JavaMail.
Transport transport = new LocalMailClientTransport();

transport.sendMessage( sm );
tranport.close();

A hitch is Transport is a class not an interface, which means you have
to carry the baggage of an actual Transport in
LocalmailClientTransport.
 

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,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top