Solved

Send Email from Java using Outlook Express

Posted on 2001-07-08
12
635 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
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 
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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
compre toata in where clue oracle 4 56
javap bin 2 28
MySQL  on Tomcat 8 27
expectj telnet failing 5 26
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

911 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

23 Experts available now in Live!

Get 1:1 Help Now