0

I want to open a new message, in the system default mail client, and include an attachment, from Java.

I tried Desktop.mail(URI mailtoURI) but I do not know how to specify the attachment.

Then, I tried JavaMail. It is working, but I am not able to open the default mail client

How to call the default mail client from within Java, and specify an attachment?

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
  • possible duplicate of [Start Mail-Client with Attachment?](http://stackoverflow.com/questions/6029579/start-mail-client-with-attachment) – jmj Jan 06 '14 at 17:26

2 Answers2

0

I don't think you can. The Desktop.mail launches mailto handler.

The mailto scheme handler only supports to, cc, subject and body.

Since the mailto scheme only supports mime type of text/plain, it does not support any attachments.

See https://www.rfc-editor.org/rfc/rfc2368

Mark Amery
  • 143,130
  • 81
  • 406
  • 459
gvaish
  • 9,374
  • 3
  • 38
  • 43
0

It doesn't seem to be possible to do this neatly, in a cross-platform way.

See Start Mail-Client with Attachment? for an explanation of how to do it in Windows

There is no agreed standard for adding attachments to messages, therefore every mail client handles it differently. This means it is not possible to write a catch-all method to do this for every possible mail client.

Community
  • 1
  • 1