How to open a mail client and automatically attach a file in java

Possible duplicate:
Java: starting a mail client with an application?

I need to create Java code that will open an email client (Outlook, Outlook Express, etc.) and automatically add a file to it. I tried using mailto, but it only opens the mail client and does not attach the file. Please help me.

Many thanks.

+4
source share
4 answers

JDIC provides some features for this. Although most of the JDIC was absorbed into java.awt.Desktop in Java 6, it did not include email composition bits. Unfortunately, the JDIC binaries disappeared from the java.net transition to the Kenai platform ; I downloaded the latest versions that I could find in the JIRA project.

JDIC does not work well in OSGi, so I recently extracted the corresponding MAPI bits into a package called jmapi .

0
source

It depends on the specific email clients, but the &attachment option should work for at least some versions of Outlook.

http://msdn.microsoft.com/en-us/library/aa767737(VS.85).aspx

+3
source

If this is a client application, you can take a look at the java.awt.Desktop class.

From javadoc ...

Launches the user default mail client mail creation window, filling in the message fields specified by mailto: URI.

Mailto: URI can specify message fields, including "to", "cc", "subject", "body", etc. See the mailto URL scheme (RFC 2368) for details of the mailto: URI specification.

This does not allow you to attach the file, but it will open the user's mail client.

This link may be useful ... Using the Desktop API in Java SE 6

+2
source

I answered an almost identical question:

Launch an email client with an attached file

0
source

All Articles