5

Possible Duplicate:
Java: Start Mail-Client with Attachment?

I need to create a java code that will open an email client (Outlook, outlook express , etc) and automatically attach a file in it. I tried using mailto but it only opens the mail client and do not attach the file. Help please.

thanks a lot.

0

4 Answers 4

2

It depends on particular email clients, but &attachment parameter should work for at least some versions of Outlook.

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

1
  • Doesn't work with Outlook 2010. Feb 6, 2015 at 14:20
2

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

From the javadoc...

Launches the mail composing window of the user default mail client, filling the message fields specified by a mailto: URI.

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

This doesn't allow you to attach a file, but it will open up the user's mail client.

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

0

JDIC provides some functionality to do this. Although much of JDIC was absorbed into java.awt.Desktop in Java 6, it didn't include the email composition bits. Unfortunately the JDIC binaries disappeared with the transition of java.net to the Kenai platform; I uploaded the most recent versions I could find to the project JIRA.

JDIC doesn't play well in OSGi, so I recently extracted the relevant MAPI bits into a bundle called jmapi.

1
  • I tried JDIC, however getting the following error: java.lang.ClassNotFoundException: org.jdesktop.jdic.desktop.internal.impl.ServiceManagerStub_unix need help.
    – vissu
    Jan 10, 2013 at 12:33
0

I answered a nearly identical question here:

Start Mail-Client with Attachment?

Not the answer you're looking for? Browse other questions tagged or ask your own question.