How to send an email attachment using a designated client, programmatically with Java

I would like to encourage our users of our RCP application to send problem information to our support department. To this end, I added the Contact Support widget to our standard error dialog.

I was able to use URI headers to send stacktrace using a Java 6 JDIC: call Desktop.getDesktop().mail(java.net.URI). This will launch the user’s email client, ready to add comments, and click “Submit”.

I like to run the mail client because this is what the user is used to, he talks a lot about the user (sigs, contact details, etc.), and I really do not want to be sent using Java Mail .

What I would like to do is attach the log file and stacktrace as a file, so the maximum length requirements are not required, and the user sees a beautiful email, and there is much more information in the support department to work with.

Can I do this with the approach I take? Or is there a better way?

Edit : I'm in an OSGi context, so JDIC binding will be necessary. If possible, I would like to supply as few dependencies as possible, and combining JDIC for multiple platforms is not very fun, especially for such a small function.

JavaMail , , . / , . JavaMail, . ?

, , Desktop.open() *.eml. Outlook Express ( Outlook) eml. , Windows, EML. ? , : a) , b) , , ?

+5
6

.eml Desktop.getDesktop(). open (emlFile)
:. , , , Outlook Express Outlook.
, ​​Windows Live Mail, .

+3

, XML-RPC, (RCP , btw) . , , , .

, - . Jira, (-, , ).

+1

, URI,

mailto:me@here.com?SUBJECT=Support mail&BODY=This is a support mail

, - ( javamail )

0

JDIC may not always be available on your user platform. A good way to do this is to use the javamail API. You can send a multi-user email as described in this SUN guide:

Sending attachments

0
source
import java.awt.Desktop;
import java.io.File;
import java.net.URI;


public class TestMail {

    public static void main(String[] args) {
        try {       
         Runtime.getRuntime().exec(
                  new String[] {"rundll32", "url.dll,FileProtocolHandler",
                        "mailto:a@a.de?subject=someSubject&cc=a@a.de&bcc=a@a.de&body=someBodyText&Attach=c:\\test\\test.doc"}, null
                  );


        } catch (Exception e) {
            e.printStackTrace();
        }
    }

}
0
source

All Articles