java - Start Mail-Client with Attachment? -


i'm searching way (in java) start default mail client defined receiver, subject , body , predefined attachment.

due limitations of rfc java.awt.desktop.mail-method not working attachments. jdic-project dead , jmapi-project rather obscure in building process. (needs 1.4 mozilla-sources) , have build 64 bit systems myself.

is there alternative? read articles here using rundl32.dll , such "solutions" aren't want put in production code.

there not appear os agnostic method of doing in java not oses provide standard way launch default e-mail application more basic fields new email.

on windows, possible use jni interface mapi, provide more control on opening email in mail application. mentioned, 1 such library jmapi - however, appears there many libraries such name similar purposes. discovered 1 maintained , seems straight-forward. includes pre-built binary dll , accompanying java jni-based library.

https://github.com/briandealwis/jmapi

with code, seems need construct message object , call method launch in mail application: import jmapi.*; ...

    if (jmapi.ismapisupported()) {         message msg = new message();         msg.setsubject("test!");         msg.setbody("hello world");          list<string> toaddresses = new linkedlist<string>();         toaddresses.add("example@example.com");         msg.settoaddrs(toaddresses);          list<string> attachpaths = new linkedlist<string>();         //must absolute paths file         attachpaths.add("c:\users\documents\file.jpg");         msg.setattachments(attachpaths);          jmapi.open(msg);     } 

another possibility might work windows , mac (and potentially other oses) generate ".eml" or ".msg" file content , attachments include encoded part of email. file launched default handler respective email file format. however, not guaranteed open default email handler, nor file format going compatible email client.


Comments

Popular posts from this blog

Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.12:test (default-test) on project.Error occurred in starting fork -

windows - Debug iNetMgr.exe unhandle exception System.Management.Automation.CmdletInvocationException -

configurationsection - activeMq-5.13.3 setup configurations for wildfly 10.0.0 -