Solved

Send Email from Java using Outlook Express

Posted on 2001-07-08
12
630 Views
Last Modified: 2013-11-24
I'm not trying to use any JavaMail API to send email here. I'm just wondering, given an email-address(string) in my Java application, can I activate Outlook Express to compose a new email. Much like clicking on an email-link when browsing using Internet Explorer

Thanks
Adams
0
Comment
Question by:spurssy
12 Comments
 
LVL 1

Expert Comment

by:goldwarlock
ID: 6263036
noway man

0
 

Expert Comment

by:sengsational
ID: 6263405
I disagree with goldwarlock.  Your Java application should be able to do this.  After all, IE or Netscape can do it.  It's just sending a message to the OS that says "start the default mail program, and send initiate a note to this email address".  If there are no answers here, I'd ask in one of the Windows topics, because what you want to know is "what's the Windows API for calling the default mail program".  Then you use JNI to call it.

--Dale--
0
 

Author Comment

by:spurssy
ID: 6263682
still hasn't got quite the answer i want...
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6264174
You can do this from in java.

You need to use runtime and call msimn.exe with a switch as follows :

start msimn.exe /mailurl:emailaddress

Here is an example of how to do it :


import java.io.*;

  public class StartMail{

    public static void main(String args[]){
      Runtime rt = Runtime.getRuntime();
      try{
          Process p = rt.exec("cmd /c start msimn.exe /mailurl:my_email@address.com");
      }catch(Exception e){
          System.err.println(e.getMessage());
       e.printStackTrace(System.err);
      }
    }
}
0
 

Expert Comment

by:anhphuongnn
ID: 6264305

i agree with ozymandias 's answer if you write java application.


0
 

Author Comment

by:spurssy
ID: 6264663
ozymandias,

Recreating your exact example, i get these following error messages:

CreateProcess: cmd /c start msimn.exe /mailurl:my_email@address.com error=0 java.io.IOException: CreateProcess: cmd /c start msimn.exe /mailurl:my_email@address.com error=0
        at java.lang.Win32Process.create(Native Method)
        at java.lang.Win32Process.<init>(Unknown Source)
        at java.lang.Runtime.execInternal(Native Method)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at StartMail.main(StartMail.java:8)
0
Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 15

Expert Comment

by:ozymandias
ID: 6264685
Works for me.

I got that error orignially when I tried to execute the command as

    start msimn.exe /mailurl:my_email@address.com

that was why I added the cmd /c to the front.

Try playing with the command to see if that helps.
If you run

    start msimn.exe /mailurl:my_email@address.com

from a command prompt does it work ?

What OS are you using ?
What JDK version are you using ?
0
 
LVL 15

Accepted Solution

by:
ozymandias earned 100 total points
ID: 6264979
Actually, this is way better because it does not rely on finding Outlook Express. It will just open the default MAPI application or whichever application has registered itself to handle the "mailto" protocol.

import java.io.*;

public class StartMail{

     public static void main(String args[]){

          Runtime rt = Runtime.getRuntime();
          try{
               Process p = rt.exec("cmd /c start mailto:my_email@address.com");
          }catch(Exception e){
               System.err.println(e.getMessage());
               e.printStackTrace(System.err);
          }
    }
}
0
 

Author Comment

by:spurssy
ID: 6265428
I tried using the command string on a command line...
it worked. But somehow, i still get the same error messages.

From the error messages, I can assume the error occured at the line where rt.exec("..") returns a Process instance. I'm just not sure what might be the cause.

I'm using Win ME and JDK1.3.

Adams
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6265464
I am using NT4 and JDK 1.3.
Did you try my last suggestion :

    cmd /c start mailto:my_email@address.com

?
0
 

Author Comment

by:spurssy
ID: 6265496
Thanks, I've got it working...

I thought I might as well remove the "cmd /c " and just carry on with "start mailto:test@test.com" it went without hitches.

Excellent work!

Adams
0
 
LVL 15

Expert Comment

by:ozymandias
ID: 6266418
Glad I could help :0)
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
This tutorial will introduce the viewer to VisualVM for the Java platform application. This video explains an example program and covers the Overview, Monitor, and Heap Dump tabs.
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now