Solved

Send Email from Java using Outlook Express

Posted on 2001-07-08
12
656 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

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 …
In this post we will learn different types of Android Layout and some basics of an Android App.
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

635 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