Solved

Send Email from Java using Outlook Express

Posted on 2001-07-08
12
636 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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
 
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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Java had always been an easily readable and understandable language.  Some relatively recent changes in the language seem to be changing this pretty fast, and anyone that had not seen any Java code for the last 5 years will possibly have issues unde…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
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 …

785 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