Question

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.

Was it helpful?

Solution

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.

OTHER TIPS

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

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

I answered a nearly identical question here:

Start Mail-Client with Attachment?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top