Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Send Email from Java using Outlook Express

Posted on 2001-07-08
12
Medium Priority
?
696 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Are you developing a Java application and want to create Excel Spreadsheets? You have come to the right place, this article will describe how you can create Excel Spreadsheets from a Java Application. For the purposes of this article, I will be u…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses

886 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